Created
May 26, 2017 18:19
-
-
Save MosesMendoza/d36dea8a0aa48a7430ed5e412f4f0f79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/puppet/graph/relationship_graph.rb b/lib/puppet/graph/relationship_graph.rb | |
index 83ee3ab..ec0f007 100644 | |
--- a/lib/puppet/graph/relationship_graph.rb | |
+++ b/lib/puppet/graph/relationship_graph.rb | |
@@ -102,8 +102,10 @@ class Puppet::Graph::RelationshipGraph < Puppet::Graph::SimpleGraph | |
overly_deferred_resource_handler = options[:overly_deferred_resource_handler] || lambda { |resource| } | |
canceled_resource_handler = options[:canceled_resource_handler] || lambda { |resource| } | |
teardown = options[:teardown] || lambda {} | |
- | |
- report_cycles_in_graph | |
+ graph_cycle_handler = options[:graph_cycle_handler] || lambda { [] } | |
+ if cycles = report_cycles_in_graph | |
+ graph_cycle_handler.call(cycles) | |
+ end | |
enqueue_roots | |
diff --git a/lib/puppet/graph/simple_graph.rb b/lib/puppet/graph/simple_graph.rb | |
index 4634619..930f30c 100644 | |
--- a/lib/puppet/graph/simple_graph.rb | |
+++ b/lib/puppet/graph/simple_graph.rb | |
@@ -240,8 +240,8 @@ class Puppet::Graph::SimpleGraph | |
#TRANSLATORS OmniGraffle and GraphViz and program names and should not be translated | |
message += _("Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz") | |
end | |
- | |
- raise Puppet::Error, message | |
+ Puppet.warning(message) | |
+ cycles | |
end | |
def write_cycles_to_graph(cycles) | |
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb | |
index b4ad1f9..175bfb0 100644 | |
--- a/lib/puppet/transaction.rb | |
+++ b/lib/puppet/transaction.rb | |
@@ -148,6 +148,17 @@ class Puppet::Transaction | |
persistence.save if catalog.host_config? | |
end | |
+ graph_cycle_handler = lambda do |cycles| | |
+ cycles.each do |cycle| | |
+ cycle.each do |resource| | |
+ resource_status(resource).failed = true | |
+ end | |
+ end | |
+ raise Puppet::Error, 'Cycle detected in graph, failing transaction.' | |
+ end | |
+ | |
+ | |
+ | |
# Generate the relationship graph, set up our generator to use it | |
# for eval_generate, then kick off our traversal. | |
generator.relationship_graph = relationship_graph | |
@@ -155,6 +166,7 @@ class Puppet::Transaction | |
:pre_process => pre_process, | |
:overly_deferred_resource_handler => overly_deferred_resource_handler, | |
:canceled_resource_handler => canceled_resource_handler, | |
+ :graph_cycle_handler => graph_cycle_handler, | |
:teardown => teardown) do |resource| | |
if resource.is_a?(Puppet::Type::Component) | |
Puppet.warning _("Somehow left a component in the relationship graph") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment