Bug #4371
Testing failures when test.pp in the puppet root has a node default
| Status: | Accepted | Start date: | 07/27/2010 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | - | % Done: | 0% | |
| Category: | testing | |||
| Target version: | - | |||
| Affected Puppet version: | Branch: | |||
| Keywords: | test leakage | |||
Description
1)
Puppet::ParseError in ‘Puppet::Resource::Catalog when compiling when converting to a RAL catalog should not lose track of resources whose names vary’
Node ‘default’ is already defined at /Users/matthewrobinson/work/puppet/test.pp:3; cannot redefine at /Users/matthewrobinson/work/puppet/test.pp:7
grammar.ra:711:in _reduce_183'
./spec/unit/resource/catalog_spec.rb:310:
/Users/matthewrobinson/work/puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:22:inrun'
/Users/matthewrobinson/work/puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:in each'
/Users/matthewrobinson/work/puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:inrun'
2)
Puppet::ParseError in ‘Puppet::Type::RelationshipMetaparam should fail if any specified resource is not found in the catalog’
Node ‘default’ is already defined at /Users/matthewrobinson/work/puppet/test.pp:3; cannot redefine at /Users/matthewrobinson/work/puppet/test.pp:7
grammar.ra:711:in _reduce_183'
./spec/unit/type_spec.rb:512:innew'
./spec/unit/type_spec.rb:512:
/Users/matthewrobinson/work/puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:22:in run'
/Users/matthewrobinson/work/puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:ineach'
/Users/matthewrobinson/work/puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:in `run'
Only saw this when running the full test suite, not just the individual test files, so the leakage may be complex.
History
#1
Updated by James Turnbull almost 3 years ago
- Status changed from Unreviewed to Accepted
#2
Updated by Matt Robinson almost 3 years ago
When you try to find a resource in the catalog, if will load files in the current directory with the name of the type. So for example
spec/unit/resource/catalog_spec.rb:324 @catalog.resource(“Test[changer2]”).should equal(resource)
results in the following stack trace where it’s going to look for a manifest called test in the current working directory.
30, 39] in /Users/matthewrobinson/work/puppet/spec/../lib/puppet/parser/type_loader.rb 30 # Import our files. 31 def import(file, current_file = nil) 32 return if Puppet[:ignoreimport] 33 34 # use a path relative to the file doing the importing => 35 if current_file 36 dir = current_file.sub(%r{[/]+$},‘’).sub(/\/$/, ‘’) 37 else 38 dir = “.” 39 end 40 pat = file 41 modname, files = Puppet::Parser::Files.find_manifests(pat, :cwd => dir, :environment => environment)
/Users/matthewrobinson/work/puppet/lib/puppet/parser/type_loader.rb:35
if current_file
(rdb:1) pp caller
[“/Users/matthewrobinson/work/puppet/spec/../lib/puppet/parser/type_loader.rb:35:in import_if_possible'",
"/Users/matthewrobinson/work/puppet/spec/../lib/puppet/parser/type_loader.rb:83:inload_until'”,
“/Users/matthewrobinson/work/puppet/spec/../lib/puppet/parser/type_loader.rb:81:in each'",
"/Users/matthewrobinson/work/puppet/spec/../lib/puppet/parser/type_loader.rb:81:inload_until'”,
“/Users/matthewrobinson/work/puppet/spec/../lib/puppet/resource/type_collection.rb:134:in find_or_load'",
"/Users/matthewrobinson/work/puppet/spec/../lib/puppet/resource/type_collection.rb:146:infind_definition'”,
“/Users/matthewrobinson/work/puppet/spec/../lib/puppet/resource.rb:369:in find_defined_resource_type'",
"/Users/matthewrobinson/work/puppet/spec/../lib/puppet/resource.rb:361:infind_resource_type'”,
“/Users/matthewrobinson/work/puppet/spec/../lib/puppet/resource.rb:450:in resolve_type'",
"/Users/matthewrobinson/work/puppet/spec/../lib/puppet/resource.rb:435:inresolve_type_and_title'”,
“/Users/matthewrobinson/work/puppet/spec/../lib/puppet/resource.rb:179:in initialize'",
"/Users/matthewrobinson/work/puppet/spec/../lib/puppet/resource/catalog.rb:371:innew'”,
“/Users/matthewrobinson/work/puppet/spec/../lib/puppet/resource/catalog.rb:371:in resource'",
"./spec/unit/resource/catalog_spec.rb:326",
"/Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_methods.rb:40:ininstance_eval'”,
“/Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_methods.rb:40:in execute'",
"/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:53:intimeout'”,
“/Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_methods.rb:37:in execute'",
"/Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:214:inrun_examples'”,
“/Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:212:in each'",
"/Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:212:inrun_examples'”,
“/Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/example/example_group_methods.rb:103:in run'",
"/Users/matthewrobinson/work/puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:22:inrun'”,
“/Users/matthewrobinson/work/puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:in each'",
"/Users/matthewrobinson/work/puppet/spec/monkey_patches/add_confine_and_runnable_to_rspec_dsl.rb:17:inrun'”,
“/Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:152:in run_examples'",
"/Library/Ruby/Gems/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:inrun'”,
“/Library/Ruby/Gems/1.8/gems/rspec-1.3.0/bin/spec:5”,
“/usr/bin/spec:19:in `load'”,
“/usr/bin/spec:19”]
I’m not clear if looking in the cwd for defined types is correct behavior. It seems to me that it should be looking in the manifestdir by default. I’m going to try making this change and see what breaks.
#3
Updated by Matt Robinson almost 3 years ago
Here’s a short way to reproduce this problem.
On the master:
site.pp (in the confdir/manifests wherever you have that)
file {‘/tmp/foo’ :
ensure => present,
require => Bar[‘lkjlkj’],
}
bar.pp (In the directory you run puppetmasterd or puppetd from) whatever you want to produce a syntax error including this sentence
Now if you run the puppet master and try to connect to it, it will follow the code path I pasted in the previous ticket update to try to find a defined type for Bar. It will look in the current working directory of both the client and the master, in that order, for files named bar to import. It will fail to import with a syntax error.
err: Could not run Puppet configuration client: Parameter require failed: Syntax error at end of file at /home/user/work/puppet/bar.pp:2
Note that Nicks patch yesterday for #4344 will prevent this from happening on the agent side, but not the master.
This update is getting long, so I’m going to in a different update send out what we should do to fix this.
#4
Updated by Matt Robinson over 2 years ago
- Assignee deleted (
Matt Robinson) - Affected Puppet version deleted (
2.6.1rc1)
This still happens. At the time I remember that I had tried to get a consensus that Puppet shouldn’t include the current working directory in the load path for puppet agent or master. I’d have to rehash that discussion though at this point since it’s been so long and I can’t remember if we agreed that it SHOULD put the cwd in the load path for puppet apply.