diff options
| author | Jesse Wolfe <jes5199@gmail.com> | 2011-04-21 18:12:22 -0700 |
|---|---|---|
| committer | Jesse Wolfe <jes5199@gmail.com> | 2011-04-21 18:12:22 -0700 |
| commit | e185be0a6d35c84a60b940f233f87c0908547dee (patch) | |
| tree | 7bc25912f6ed0f41fa4cf7fd15dbc10ab87db550 | |
| parent | dc378c024a08c2b989297ad2f8ed50830baf0dcf (diff) | |
| parent | 5c245418115396df655f86065d2d1d3af62e39ee (diff) | |
Merge branch 'ticket/2.7.x/7084' into 2.7.x
| -rw-r--r-- | lib/puppet/resource/catalog.rb | 14 | ||||
| -rw-r--r-- | lib/puppet/transaction/event_manager.rb | 17 | ||||
| -rw-r--r-- | lib/puppet/type/whit.rb | 8 | ||||
| -rwxr-xr-x | spec/unit/simple_graph_spec.rb | 18 | ||||
| -rwxr-xr-x | spec/unit/type/whit_spec.rb | 2 |
5 files changed, 41 insertions, 18 deletions
diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index a6cff9bdc..b742d283f 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -74,7 +74,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph raise ArgumentError, "Can only add objects that respond to :ref, not instances of #{resource.class}" unless resource.respond_to?(:ref) fail_on_duplicate_type_and_title(resource) title_key = title_key_for_ref(resource.ref) - + @transient_resources << resource if applying? @resource_table[title_key] = resource @@ -339,8 +339,8 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph @relationship_graph end - # Impose our container information on another graph by using it - # to replace any container vertices X with a pair of verticies + # Impose our container information on another graph by using it + # to replace any container vertices X with a pair of verticies # { admissible_X and completed_X } such that that # # 0) completed_X depends on admissible_X @@ -353,8 +353,8 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph # Note that this requires attention to the possible case of containers # which contain or depend on other containers, but has the advantage # that the number of new edges created scales linearly with the number - # of contained verticies regardless of how containers are related; - # alternatives such as replacing container-edges with content-edges + # of contained verticies regardless of how containers are related; + # alternatives such as replacing container-edges with content-edges # scale as the product of the number of external dependences, which is # to say geometrically in the case of nested / chained containers. # @@ -374,8 +374,8 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph admissible = Hash.new { |h,k| k } completed = Hash.new { |h,k| k } containers.each { |x| - admissible[x] = whit_class.new(:name => "admissible_#{x.name}", :catalog => self) - completed[x] = whit_class.new(:name => "completed_#{x.name}", :catalog => self) + admissible[x] = whit_class.new(:name => "admissible_#{x.ref}", :catalog => self) + completed[x] = whit_class.new(:name => "completed_#{x.ref}", :catalog => self) } # # Implement the six requierments listed above diff --git a/lib/puppet/transaction/event_manager.rb b/lib/puppet/transaction/event_manager.rb index f5da870ed..8f1a695af 100644 --- a/lib/puppet/transaction/event_manager.rb +++ b/lib/puppet/transaction/event_manager.rb @@ -62,7 +62,18 @@ class Puppet::Transaction::EventManager end def queue_events_for_resource(source, target, callback, events) - source.info "Scheduling #{callback} of #{target}" + whit = Puppet::Type.type(:whit) + + # The message that a resource is refreshing the completed-whit for its own class + # is extremely counter-intuitive. Basically everything else is easy to understand, + # if you suppress the whit-lookingness of the whit resources + refreshing_c_whit = target.is_a?(whit) && target.name =~ /^completed_/ + + if refreshing_c_whit + source.debug "The container #{target} will propagate my #{callback} event" + else + source.info "Scheduling #{callback} of #{target}" + end @event_queues[target] ||= {} @event_queues[target][callback] ||= [] @@ -82,7 +93,9 @@ class Puppet::Transaction::EventManager process_noop_events(resource, callback, events) and return false unless events.detect { |e| e.status != "noop" } resource.send(callback) - resource.notice "Triggered '#{callback}' from #{events.length} events" + if not resource.is_a?(Puppet::Type.type(:whit)) + resource.notice "Triggered '#{callback}' from #{events.length} events" + end return true rescue => detail resource.err "Failed to call #{callback}: #{detail}" diff --git a/lib/puppet/type/whit.rb b/lib/puppet/type/whit.rb index 55ed0386e..4c77915b3 100644 --- a/lib/puppet/type/whit.rb +++ b/lib/puppet/type/whit.rb @@ -5,8 +5,14 @@ Puppet::Type.newtype(:whit) do desc "The name of the whit, because it must have one." end + + # Hide the fact that we're a whit from logs def to_s - "(#{name})" + name.sub(/^completed_|^admissible_/, "") + end + + def path + to_s end def refresh diff --git a/spec/unit/simple_graph_spec.rb b/spec/unit/simple_graph_spec.rb index c8fea3b58..472ebbd36 100755 --- a/spec/unit/simple_graph_spec.rb +++ b/spec/unit/simple_graph_spec.rb @@ -525,6 +525,10 @@ describe Puppet::SimpleGraph do def to_s @name end + + def ref + "Container[#{self}]" + end end require "puppet/resource/catalog" @@ -536,7 +540,7 @@ describe Puppet::SimpleGraph do @middle = Container.new("middle", ["e", "f", @two]) @top = Container.new("top", ["g", "h", @middle, @one, @three]) @empty = Container.new("empty", []) - + @whit = Puppet::Type.type(:whit) @stage = Puppet::Type.type(:stage).new(:name => "foo") @@ -574,7 +578,7 @@ describe Puppet::SimpleGraph do end def whit_called(name) - x = @depgraph.vertices.find { |v| v.is_a?(@whit) && v.name =~ /#{name}/ } + x = @depgraph.vertices.find { |v| v.is_a?(@whit) && v.name =~ /#{Regexp.escape(name)}/ } x.should_not be_nil def x.to_s "Whit[#{name}]" @@ -586,11 +590,11 @@ describe Puppet::SimpleGraph do end def admissible_sentinal_of(x) - @depgraph.vertex?(x) ? x : whit_called("admissible_#{x.name}") + @depgraph.vertex?(x) ? x : whit_called("admissible_#{x.ref}") end def completed_sentinal_of(x) - @depgraph.vertex?(x) ? x : whit_called("completed_#{x.name}") + @depgraph.vertex?(x) ? x : whit_called("completed_#{x.ref}") end before do @@ -618,7 +622,7 @@ describe Puppet::SimpleGraph do # 0) completed_X depends on admissible_X # it "every container's completed sentinal should depend on its admissible sentinal" do - containers.each { |container| + containers.each { |container| @depgraph.path_between(admissible_sentinal_of(container),completed_sentinal_of(container)).should be } end @@ -626,7 +630,7 @@ describe Puppet::SimpleGraph do # 1) contents of X each depend on admissible_X # it "all contained objects should depend on their container's admissible sentinal" do - containers.each { |container| + containers.each { |container| contents_of(container).each { |leaf| @depgraph.should be_edge(admissible_sentinal_of(container),admissible_sentinal_of(leaf)) } @@ -636,7 +640,7 @@ describe Puppet::SimpleGraph do # 2) completed_X depends on each on the contents of X # it "completed sentinals should depend on their container's contents" do - containers.each { |container| + containers.each { |container| contents_of(container).each { |leaf| @depgraph.should be_edge(completed_sentinal_of(leaf),completed_sentinal_of(container)) } diff --git a/spec/unit/type/whit_spec.rb b/spec/unit/type/whit_spec.rb index 4d0949900..9a076d1f1 100755 --- a/spec/unit/type/whit_spec.rb +++ b/spec/unit/type/whit_spec.rb @@ -5,6 +5,6 @@ whit = Puppet::Type.type(:whit).new(:name => "Foo::Bar") describe whit do it "should stringify in a way that users will regognise" do - whit.to_s.should == "(Foo::Bar)" + whit.to_s.should == "Foo::Bar" end end |
