[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.1rc1-141-gcdb2b90

Markus Roberts Markus at reality.com
Mon Aug 16 12:48:00 UTC 2010


The following commit has been merged in the upstream branch:
commit 59a23d69c20a8ab1f7dc9ff1d109305f9027641c
Author: Markus Roberts <Markus at reality.com>
Date:   Sat Jul 24 14:48:13 2010 -0700

    Fix for #3382 -- Empty classes as graph placeholders
    
    As Brice discovered, the problem was that we simply ignored empty classes in
    the graph when determining application order.  This patch instead replaces them
    with a resource of a new type which we've frequently noted the (internal) need
    for: a whit, the smallest possible resource, which has no properties or other
    semantics apart from its existence and its name.
    
    This resource then ensures application order through the normal mechanisms.

diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index 945b1be..55b39fa 100644
--- a/lib/puppet/simple_graph.rb
+++ b/lib/puppet/simple_graph.rb
@@ -318,16 +318,15 @@ class Puppet::SimpleGraph
     # to container leaves, but that would result in many more
     # relationships.
     stage_class = Puppet::Type.type(:stage)
+    whit_class  = Puppet::Type.type(:whit)
     containers = other.topsort.find_all { |v| (v.is_a?(type) or v.is_a?(stage_class)) and vertex?(v) }
     containers.each do |container|
       # Get the list of children from the other graph.
       children = other.adjacent(container, :direction => :out)
 
-      # Just remove the container if it's empty.
-      if children.empty?
-        remove_vertex!(container)
-        next
-      end
+      # MQR TODO: Luke suggests that it should be possible to refactor the system so that
+      #           container nodes are retained, thus obviating the need for the whit. 
+      children = [whit_class.new(:name => container.name, :catalog => other)] if children.empty?
 
       # First create new edges for each of the :in edges
       [:in, :out].each do |dir|
diff --git a/lib/puppet/type/whit.rb b/lib/puppet/type/whit.rb
new file mode 100644
index 0000000..6e5ba9e
--- /dev/null
+++ b/lib/puppet/type/whit.rb
@@ -0,0 +1,7 @@
+Puppet::Type.newtype(:whit) do
+  desc "The smallest possible resource type, for when you need a resource and naught else."
+
+  newparam :name do
+    desc "The name of the whit, because it must have one."
+  end
+end
diff --git a/spec/unit/simple_graph_spec.rb b/spec/unit/simple_graph_spec.rb
index 83e6741..2ca8888 100755
--- a/spec/unit/simple_graph_spec.rb
+++ b/spec/unit/simple_graph_spec.rb
@@ -439,7 +439,8 @@ 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")
 
       @contgraph = @top.to_graph
@@ -499,8 +500,17 @@ describe Puppet::SimpleGraph do
       end
     end
 
+    it "should contain a whit-resource to mark the place held by the empty container" do
+      @depgraph.vertices.find_all { |v| v.is_a?(@whit) }.length.should == 1
+    end
+
+    it "should replace edges to empty containers with edges to their residual whit" do
+      emptys_whit = @depgraph.vertices.find_all { |v| v.is_a?(@whit) }.first
+      @depgraph.should be_edge("c", emptys_whit)
+    end
+
     it "should no longer contain anything but the non-container objects" do
-      @depgraph.vertices.find_all { |v| ! v.is_a?(String) }.should be_empty
+      @depgraph.vertices.find_all { |v| ! v.is_a?(String) and ! v.is_a?(@whit)}.should be_empty
     end
 
     it "should copy labels" do

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list