diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/pgraph.rb | 15 | ||||
-rw-r--r-- | lib/puppet/transaction.rb | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb index 393f88449..894a8fe03 100644 --- a/lib/puppet/pgraph.rb +++ b/lib/puppet/pgraph.rb @@ -50,6 +50,21 @@ class Puppet::PGraph < GRATR::Digraph end end + # Fail in a somewhat informative way if the graph has become cyclic. + def check_cycle + sorted = topsort() + return true if sorted.size == size() + + bad = [] + vertices.each do |v| + bad << v unless sorted.include?(v) + end + + raise Puppet::Error, "Found cycle involving %s" % bad.collect do |v| + v.to_s + end.join(", ") + end + # Which resources a given resource depends upon. def dependents(resource) tree_from_vertex2(resource).keys diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index b4d4c8512..33874f83e 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -38,6 +38,7 @@ class Transaction # Apply all changes for a resource, returning a list of the events # generated. def apply(resource) + resource.info "Applying" begin changes = resource.evaluate rescue => detail @@ -458,6 +459,8 @@ class Transaction # Then splice in the container information graph.splice!(@resources, Puppet::Type::Component) + graph.check_cycle + graph(graph, :expanded_relationships) return graph |