summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-24 14:48:13 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-24 23:39:14 -0700
commit59a23d69c20a8ab1f7dc9ff1d109305f9027641c (patch)
tree14df249a73f45d5627d0069c619b270f4e24d1e8 /lib
parent865282ae7b9332fdbdfa51b2814755b8a13d244b (diff)
downloadpuppet-59a23d69c20a8ab1f7dc9ff1d109305f9027641c.tar.gz
puppet-59a23d69c20a8ab1f7dc9ff1d109305f9027641c.tar.xz
puppet-59a23d69c20a8ab1f7dc9ff1d109305f9027641c.zip
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/simple_graph.rb9
-rw-r--r--lib/puppet/type/whit.rb7
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index 945b1beb3..55b39fadf 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 000000000..6e5ba9eab
--- /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