This patch changes the logging behavior of Whits so that instead of
talking about whits directly, we refer to the Class, Stage, or recursive
resource that they are sentinals for.
In the case where a "completion" Whit is notified by a resource, getting
a notification at all is counterinutitive, so I've changed the output to
a "debug"-priority message that describes what's happening.

Reviewed-By: Nick Lewis <[email protected]>
Signed-off-by: Jesse Wolfe <[email protected]>
---
Local-branch: ticket/2.7.x/7084
 lib/puppet/resource/catalog.rb          |   14 +++++++-------
 lib/puppet/transaction/event_manager.rb |   17 +++++++++++++++--
 lib/puppet/type/whit.rb                 |    8 +++++++-
 spec/unit/simple_graph_spec.rb          |   18 +++++++++++-------
 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 a6cff9b..b742d28 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 f5da870..8f1a695 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 55ed038..4c77915 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 c8fea3b..472ebbd 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 4d09499..9a076d1 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
-- 
1.7.3.5

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to