diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-28 05:32:03 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-02-28 05:32:03 +0000 |
commit | be8dfd92b4d1212a9beaa520f80043fe67e0bbbb (patch) | |
tree | 314dfaa24b7534057a6e9b3f1356416cee7d59d6 | |
parent | 4df0738de2e93b8c0408561153543682aa1a3455 (diff) | |
download | puppet-be8dfd92b4d1212a9beaa520f80043fe67e0bbbb.tar.gz puppet-be8dfd92b4d1212a9beaa520f80043fe67e0bbbb.tar.xz puppet-be8dfd92b4d1212a9beaa520f80043fe67e0bbbb.zip |
Fixing a problem with the splice! method on the graphing. The problem was another issue with hash ordering, where it would usually work but sometimes start failing. The solution was to splice the containers in topological-sort order.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2240 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/pgraph.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb index fe55533d9..bd61b01ff 100644 --- a/lib/puppet/pgraph.rb +++ b/lib/puppet/pgraph.rb @@ -117,7 +117,14 @@ class Puppet::PGraph < GRATR::Digraph # This creates direct relationships where there were previously # indirect relationships through the containers. def splice!(other, type) - vertices.find_all { |v| v.is_a?(type) }.each do |container| + # We have to get the container list via a topological sort on the + # configuration graph, because otherwise containers that contain + # other containers will add those containers back into the + # graph. We could get a similar affect by only setting relationships + # to container leaves, but that would result in many more + # relationships. + containers = other.topsort.find_all { |v| v.is_a?(type) and vertex?(v) } + containers.each do |container| # Get the list of children from the other graph. children = other.adjacent(container, :direction => :out) @@ -129,7 +136,8 @@ class Puppet::PGraph < GRATR::Digraph # First create new edges for each of the :in edges [:in, :out].each do |dir| - adjacent(container, :direction => dir, :type => :edges).each do |edge| + edges = adjacent(container, :direction => dir, :type => :edges) + edges.each do |edge| children.each do |child| if dir == :in s = edge.source @@ -159,6 +167,8 @@ class Puppet::PGraph < GRATR::Digraph # Now get rid of the edge, so remove_vertex! works correctly. remove_edge!(edge) + Puppet.debug "%s: %s => %s: %s" % [container, + edge.source, edge.target, edge?(edge)] end end remove_vertex!(container) |