Bug #923

test_storeandcollect(TestScope) doesn't find some of the exported resources

Added by David Schmitt over 4 years ago. Updated over 4 years ago.

Status:Closed Start date:
Priority:High Due date:
Assignee:Puppet Community % Done:

0%

Category:language
Target version:0.24.0
Affected Puppet version:0.25.4 Branch:
Keywords:
Votes: 0

Description

Adding debug output shows that this happens already on the first pass of the loop at line 420:

  9) Failure:
test_storeandcollect(TestScope)
    [./language/scope.rb:428:in @test_storeandcollect'
     ./language/scope.rb:427:in @each'
     ./language/scope.rb:427:in @test_storeandcollect'
     ./language/scope.rb:420:in @times'
     ./language/scope.rb:420:in @test_storeandcollect'
     /tests/puppet-trunk/test/lib/mocha/test_case_adapter.rb:19:in @+send+'
     /tests/puppet-trunk/test/lib/mocha/test_case_adapter.rb:19:in @run']:
Did not find puppet.
 is not true.

History

Updated by David Schmitt over 4 years ago

This looks like a genuine bug regarding collection, therefore I set a higher priority

Updated by Luke Kanies over 4 years ago

This happens consistently for you? I can’t reproduce it.

Updated by David Schmitt over 4 years ago

This test now works for me, but this only hides a bigger problem: commit:fc7f1b4f70d8e4b62852a0da0af21fcb67a1a89c unsets the “exported” flag on resources before they are stored in the DB. As you can imagine, this leads to havoc, since this causes resources to never be marked as exported in the DB.

This can be observed by applying this patch:

diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 3f34616..7318b3b 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -72,6 +72,9 @@ class Puppet::Parser::Resource
     # Mark this resource as both exported and virtual,
     # or remove the exported mark.
     def exported=(value)
+                       if @exported and not value
+                                         devfail "Resource %s got un-exported!"
+                       end
         if value
             @virtual = true
             @exported = value

which leads to this error:

  1) Failure:
test_storeandcollect(TestScope)
    [./language/scope.rb:421:in @test_storeandcollect'
     ./language/scope.rb:420:in @times'
     ./language/scope.rb:420:in @test_storeandcollect'
     /home/david/trunk/test/lib/mocha/test_case_adapter.rb:19:in @+send+'
     /home/david/trunk/test/lib/mocha/test_case_adapter.rb:19:in @run']:
Exception raised:
Class: 
Message: <"REsource %s got un-exported! at line 3">
---Backtrace---
/home/david/trunk/lib/puppet/util/errors.rb:51:in @fail'
/home/david/trunk/lib/puppet/util/errors.rb:5:in @devfail'
/home/david/trunk/lib/puppet/parser/resource.rb:76:in @exported='
/home/david/trunk/lib/puppet/parser/collector.rb:19:in @evaluate'
/home/david/trunk/lib/puppet/parser/collector.rb:17:in @each'
/home/david/trunk/lib/puppet/parser/collector.rb:17:in @evaluate'
/home/david/trunk/lib/puppet/parser/compile.rb:276:in @evaluate_collections'
/home/david/trunk/lib/puppet/parser/compile.rb:275:in @each'
/home/david/trunk/lib/puppet/parser/compile.rb:275:in @evaluate_collections'
/home/david/trunk/lib/puppet/util/errors.rb:25:in @exceptwrap'
/home/david/trunk/lib/puppet/parser/compile.rb:271:in @evaluate_collections'
/home/david/trunk/lib/puppet/parser/compile.rb:310:in @evaluate_generators'
/home/david/trunk/lib/puppet/parser/compile.rb:306:in @loop'
/home/david/trunk/lib/puppet/parser/compile.rb:306:in @evaluate_generators'
/home/david/trunk/lib/puppet/parser/compile.rb:73:in @compile'
/home/david/trunk/lib/puppet/parser/interpreter.rb:28:in @compile'
./language/scope.rb:422:in @test_storeandcollect'
./language/scope.rb:421:in @test_storeandcollect'
./language/scope.rb:420:in @times'
./language/scope.rb:420:in @test_storeandcollect'
/home/david/trunk/test/lib/mocha/test_case_adapter.rb:19:in @+send+'
/home/david/trunk/test/lib/mocha/test_case_adapter.rb:19:in @run'
---------------

The backtrace shows that this is still deep in the parser, and testing with a puppetmaster also confirms, that this is the cause why no resources are stored as exported.

Updated by David Schmitt over 4 years ago

Replying to [comment:3 DavidS]:

This test now works for me, but this only hides a bigger problem: commit:fc7f1b4f70d8e4b62852a0da0af21fcb67a1a89c unsets the “exported” flag on resources before they are stored in the DB.

… on line 19 of

lib/puppet/parser/collector.rb

As you can imagine, this leads to havoc, since this causes resources to never be marked as exported in the DB.

Updated by Luke Kanies over 4 years ago

  • Status changed from 1 to Closed
  • 7 set to fixed

Fixed in commit:038b9c8d571581f13acc202a9dbbcf7e1f325ab3.

Updated by Luke Kanies over 4 years ago

  • Status changed from Closed to 4
  • 7 deleted (fixed)

Apparently this fix causes resources from the local host to conflict with its stored resources.

Updated by David Schmitt over 4 years ago

On the second and further runs after re-creating the storeconfigs DB, this error is reported:

err: Could not retrieve configuration: Exported resource File[/...] cannot override local resource

The trace shows that the failure is in

lib/puppet/parser/collector.rb:exported_resource
when
existing.rails_id
is empty. Since this doesn’t occur on the second run, I suppose the “existing” resource is coming from the current compile and the obj (Puppet::Rails::Resource) is coming from the last compile run.

Updated by David Schmitt over 4 years ago

Ah, here is the host table of my DB:

  1 | git-test.black.co.at | 192.168.0.7 | 2007-12-10 16:55:59 |                 |             | 2007-12-10 16:55:59 |               
  2 | git-test.black.co.at | 192.168.0.7 | 2007-12-10 16:56:52 |                 |             | 2007-12-10 16:56:52 |               

That doesn’t look good.

Updated by Luke Kanies over 4 years ago

  • Status changed from 4 to Closed
  • 7 set to fixed

Fixed in [ae33e57]. The method that stored a host to the db was not correctly searching for the old host, so it was always creating a new host.

Also available in: Atom PDF