diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-01-23 13:49:32 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-01-23 13:49:32 +0000 |
| commit | c285d7af0eea29e787eb889d393145da72402b56 (patch) | |
| tree | 029348f6d15952429d9400c6693f3c59187b3e9b /lib/puppet | |
| parent | 9720a9764155b707126c2254fab3fa4d2516b352 (diff) | |
| download | puppet-c285d7af0eea29e787eb889d393145da72402b56.tar.gz puppet-c285d7af0eea29e787eb889d393145da72402b56.tar.xz puppet-c285d7af0eea29e787eb889d393145da72402b56.zip | |
Fixing #437. Transactions now check whether graphs are cyclic, with a somewhat-useful error message if they are.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2079 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
| -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 |
