Bug #5392
Misleading error message when trying to collect resources of an undefined type
| Status: | Closed | Start date: | 11/24/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | - | |||
| Target version: | 2.6.7 | |||
| Affected Puppet version: | Branch: | https://github.com/duritong/puppet/tree/ticket/2.6.x/5392 | ||
| Keywords: | communitypatch | |||
| Votes: | 1 |
Description
On 2.6.3 I get the following error:
/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/collection.rb:19:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:35:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `collect' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/resource/type.rb:76:in `evaluate_code' /usr/lib/ruby/site_ruby/1.8/puppet/parser/resource.rb:71:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/resource/type.rb:295:in `evaluate_parent_type' /usr/lib/ruby/site_ruby/1.8/puppet/resource/type.rb:67:in `evaluate_code' /usr/lib/ruby/site_ruby/1.8/puppet/parser/resource.rb:71:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:151:in `evaluate_classes' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:142:in `each' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:142:in `evaluate_classes' /usr/lib/ruby/site_ruby/1.8/puppet/parser/functions/include.rb:6:in `function_include' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/function.rb:33:in `send' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/function.rb:33:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:35:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `collect' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/caseopt.rb:61:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/casestatement.rb:25:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/caseopt.rb:54:in `eachopt' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/casestatement.rb:24:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/branch.rb:16:in `each' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/branch.rb:15:in `each' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/casestatement.rb:23:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:35:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `collect' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/resource/type.rb:76:in `evaluate_code' /usr/lib/ruby/site_ruby/1.8/puppet/parser/resource.rb:71:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:151:in `evaluate_classes' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:142:in `each' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:142:in `evaluate_classes' /usr/lib/ruby/site_ruby/1.8/puppet/parser/functions/include.rb:6:in `function_include' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/function.rb:33:in `send' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/function.rb:33:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:35:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `collect' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/resource/type.rb:76:in `evaluate_code' /usr/lib/ruby/site_ruby/1.8/puppet/parser/resource.rb:71:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:151:in `evaluate_classes' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:142:in `each' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:142:in `evaluate_classes' /usr/lib/ruby/site_ruby/1.8/puppet/parser/functions/include.rb:6:in `function_include' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/function.rb:33:in `send' [57/222] /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/function.rb:33:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:35:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `collect' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/resource/type.rb:76:in `evaluate_code' /usr/lib/ruby/site_ruby/1.8/puppet/parser/resource.rb:71:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:151:in `evaluate_classes' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:142:in `each' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:142:in `evaluate_classes' /usr/lib/ruby/site_ruby/1.8/puppet/parser/functions/include.rb:6:in `function_include' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/function.rb:33:in `send' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/function.rb:33:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:35:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `collect' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/astarray.rb:34:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/ast.rb:72:in `safeevaluate' /usr/lib/ruby/site_ruby/1.8/puppet/resource/type.rb:76:in `evaluate_code' /usr/lib/ruby/site_ruby/1.8/puppet/parser/resource.rb:71:in `evaluate' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:225:in `evaluate_ast_node' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:103:in `compile' /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:18:in `compile' /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in `compile' /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:192:in `benchmark' /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb:10:in `realtime' /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:191:in `benchmark' /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in `compile' /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:34:in `find' /usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:193:in `find' /usr/lib/ruby/site_ruby/1.8/puppet/indirector.rb:50:in `find' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:101:in `do_find' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:68:in `send' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:68:in `process' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick/rest.rb:24:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:45:in `listen' /usr/lib/ruby/1.8/webrick/server.rb:173:in `call' /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/lib/ruby/1.8/webrick/server.rb:92:in `each' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:42:in `listen' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `initialize' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `new' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `listen' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:38:in `synchronize' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:38:in `listen' /usr/lib/ruby/site_ruby/1.8/puppet/network/server.rb:127:in `listen' [2/222] /usr/lib/ruby/site_ruby/1.8/puppet/network/server.rb:142:in `start' /usr/lib/ruby/site_ruby/1.8/puppet/daemon.rb:124:in `start' /usr/lib/ruby/site_ruby/1.8/puppet/application/master.rb:114:in `main' /usr/lib/ruby/site_ruby/1.8/puppet/application/master.rb:46:in `run_command' /usr/lib/ruby/site_ruby/1.8/puppet/application.rb:287:in `run' /usr/lib/ruby/site_ruby/1.8/puppet/application.rb:393:in `exit_on_fail' /usr/lib/ruby/site_ruby/1.8/puppet/application.rb:287:in `run' /usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:55:in `execute' /usr/bin/puppet:4 err: undefined method `name' for nil:NilClass at /srv/puppet/development/modules/public/nagios/manifests/base.pp:77 on node foo.bar.ch /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:21:in `compile' /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in `compile' /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:192:in `benchmark' /usr/lib64/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/benchmark.rb:10:in `realtime' /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:191:in `benchmark' /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in `compile' /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:34:in `find' /usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:193:in `find' /usr/lib/ruby/site_ruby/1.8/puppet/indirector.rb:50:in `find' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:101:in `do_find' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:68:in `send' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:68:in `process' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick/rest.rb:24:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:45:in `listen' /usr/lib/ruby/1.8/webrick/server.rb:173:in `call' /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/lib/ruby/1.8/webrick/server.rb:92:in `each' /usr/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start' /usr/lib/ruby/1.8/webrick/server.rb:82:in `start' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:42:in `listen' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `initialize' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `new' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:41:in `listen' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:38:in `synchronize' /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:38:in `listen' /usr/lib/ruby/site_ruby/1.8/puppet/network/server.rb:127:in `listen' /usr/lib/ruby/site_ruby/1.8/puppet/network/server.rb:142:in `start' /usr/lib/ruby/site_ruby/1.8/puppet/daemon.rb:124:in `start' /usr/lib/ruby/site_ruby/1.8/puppet/application/master.rb:114:in `main' /usr/lib/ruby/site_ruby/1.8/puppet/application/master.rb:46:in `run_command' /usr/lib/ruby/site_ruby/1.8/puppet/application.rb:287:in `run' /usr/lib/ruby/site_ruby/1.8/puppet/application.rb:393:in `exit_on_fail' /usr/lib/ruby/site_ruby/1.8/puppet/application.rb:287:in `run' /usr/lib/ruby/site_ruby/1.8/puppet/util/command_line.rb:55:in `execute' /usr/bin/puppet:4 err: undefined method `name' for nil:NilClass at /srv/puppet/development/modules/public/nagios/manifests/base.pp:77 on node foo.bar.ch
As I’m collecting other exported resources on other hosts and it works fine there I assume it has to do either with the kind of resource or one of the exported resources is broken.
History
Updated by Peter Meier over 1 year ago
So some debugging more I figured out that the offending line is not 77 but 76. I figured that out because when I commented out 77 I got an error on 78, etc. If I comment out 77 I got another error on 84 (which actually meant 83) and finally another one on 125 which is the end of the same exported resource on 83.
So after commenting the collection of these resources out the catalog compiled.
So the next is, that I’m going to look into the database whether one of the exported resources of that type is “weird”.
Updated by Peter Meier over 1 year ago
the link got somehow lost: base.pp line 77
Updated by Peter Meier over 1 year ago
ok actually I figured out that puppet only fails on collecting exported resources where no resources are actually exported. Because I currently have no resources of type Nagios_plugin or Nagios_hostgroupescalation exported.
So in lib/puppet/parser/ast/collection.rb on line 18 we get nil back when @type == 'nagios_plugin'
So we have a problem that puppet is not able to find the type for empty collection of an exported resources.
My quickfix for that which seems to work:
diff --git a/lib/puppet/parser/ast/collection.rb b/lib/puppet/parser/ast/collection.rb
index ef36b71..5c8ab69 100644
--- a/lib/puppet/parser/ast/collection.rb
+++ b/lib/puppet/parser/ast/collection.rb
@@ -16,6 +16,7 @@ class Puppet::Parser::AST
str, code = query && query.safeevaluate(scope)
resource_type = scope.find_resource_type(@type)
+ return unless resource_type
newcoll = Puppet::Parser::Collector.new(scope, resource_type.name, str, code, self.form)
scope.compiler.add_collection(newcoll)
Sounds resonable?
Updated by Peter Meier over 1 year ago
- Subject changed from compile fails while collecting certain exported resource to compile fails while collecting an empty list of exported resources
Updated by Nigel Kersten over 1 year ago
- Status changed from Unreviewed to Accepted
We should send this to the dev-list for comment. Would you like to do that Peter? or I can do it on your behalf.
Updated by Peter Meier over 1 year ago
Nigel Kersten wrote:
We should send this to the dev-list for comment. Would you like to do that Peter? or I can do it on your behalf.
it was a very late night quickfix. It worked on my infrastructure™ but I didn’t yet look into possible side effects. Will write tests and send it then to the dev-list. Thanks.
Updated by Peter Meier over 1 year ago
- Branch set to https://github.com/duritong/puppet/tree/ticket/2.6.x/5392
patch sent do -dev list and branch up on github
Updated by Matt Robinson over 1 year ago
- Keywords set to communitypatch
Updated by Paul Berry over 1 year ago
Peter—
Are you aware that the nagios_hostgroupescalation type was removed in version 0.24.7?
It looks to me like the bug is that if you try to collect resources of an unrecognized type you get a bogus error message. For example, this manifest reproduces your failure:
Bogus_type <| title == 'foo' |>
But this works fine:
define bogus_type($arg) { file { '/tmp/foo': } }
Bogus_type <| title == 'foo' |>
If I’m understanding the bug correctly, it looks like we should fix it by improving the error message, not by skipping the collection when the type can’t be found.
Updated by Peter Meier over 1 year ago
Are you aware that the nagios_hostgroupescalation type was removed in version 0.24.7?
uhh, eh, no. :/ Also nagios_plugins… interesting. The error never appeared until 2.6.3, so probably a recent change made that issue more clear. Anyway, then the error make sense, …
If I’m understanding the bug correctly, it looks like we should fix it by improving the error message, not by skipping the collection when the type can’t be found.
… and yes we should improve the error message. Do you like to do it?
Updated by Paul Berry over 1 year ago
- Subject changed from compile fails while collecting an empty list of exported resources to Misleading error message when trying to collect resources of an undefined type
- Keywords deleted (
communitypatch)
Updated the bug title to reflect that the problem is a misleading error message.
Updated by Matt Robinson over 1 year ago
- Status changed from Accepted to In Topic Branch Pending Review
- Keywords set to communitypatch
Updated by Mark Washeim over 1 year ago
I can confirm that the aforementioned patch in collection.rb also obtains for 2.6.4. 2.6.2 does not display this problem. It seems to be triggered by nagios service definitions which worked fine in 2.5.x – 2.6.2
Updated by Mark Washeim over 1 year ago
Mark Washeim wrote:
I can confirm that the aforementioned patch in collection.rb also obtains for 2.6.4. 2.6.2 does not display this problem. It seems to be triggered by nagios service definitions which worked fine in 2.5.x – 2.6.2
I can confirm that this bug obtains WITH my manifests for nagios in 2.6.5rc1.
Soooo, either something has changed in the naginator??? or we’ve misused a novel gap in the language itself.
Updated by James Turnbull about 1 year ago
- Status changed from In Topic Branch Pending Review to Needs Decision
- Assignee set to Nigel Kersten
Updated by Matt Robinson about 1 year ago
- Status changed from Needs Decision to Merged - Pending Release
Not sure what decision was needed here, but the ticket boiled down to we should have a better error message when you try to realize a resource that didn’t exist. I’ve just pushed commit:285c4cc4b056b9c4990738c3d479d1a8993cf959 to do this. Peter, thanks for the original patch, I didn’t end up using the code since it returned instead of raised, but it pointed out the problem area to me.
Updated by Nigel Kersten about 1 year ago
Thanks for digging into this Matt. I did a quick skim of the thread and hadn’t reached a point where I understood what was going on yet.
Updated by James Turnbull about 1 year ago
- Target version changed from 2.6.x to 2.6.7
Updated by James Turnbull about 1 year ago
- Status changed from Merged - Pending Release to Closed