summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/transaction.rb82
1 files changed, 45 insertions, 37 deletions
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index 54163c521..80e0d49c5 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -202,43 +202,7 @@ class Transaction
if checkskip and skip?(resource)
@resourcemetrics[:skipped] += 1
else
- @resourcemetrics[:scheduled] += 1
-
- changecount = @changes.length
-
- # We need to generate first regardless, because the recursive
- # actions sometimes change how the top resource is applied.
- children = eval_generate(resource)
-
- if children and resource.depthfirst?
- children.each do |child|
- # The child will never be skipped when the parent isn't
- events += eval_resource(child, false)
- end
- end
-
- # Perform the actual changes
- seconds = thinmark do
- events += apply(resource)
- end
-
- if children and ! resource.depthfirst?
- children.each do |child|
- events += eval_resource(child, false)
- end
- end
-
- # A bit of hackery here -- if skipcheck is true, then we're the
- # top-level resource. If that's the case, then make sure all of
- # the changes list this resource as a proxy. This is really only
- # necessary for rollback, since we know the generating resource
- # during forward changes.
- if children and checkskip
- @changes[changecount..-1].each { |change| change.proxy = resource }
- end
-
- # Keep track of how long we spend in each type of resource
- @timemetrics[resource.class.name] += seconds
+ events += eval_children_and_apply_resource(resource, checkskip)
end
# Check to see if there are any events for this resource
@@ -262,6 +226,50 @@ class Transaction
events
end
+ def eval_children_and_apply_resource(resource, checkskip)
+ events = []
+
+ @resourcemetrics[:scheduled] += 1
+
+ changecount = @changes.length
+
+ # We need to generate first regardless, because the recursive
+ # actions sometimes change how the top resource is applied.
+ children = eval_generate(resource)
+
+ if children and resource.depthfirst?
+ children.each do |child|
+ # The child will never be skipped when the parent isn't
+ events += eval_resource(child, false)
+ end
+ end
+
+ # Perform the actual changes
+ seconds = thinmark do
+ events += apply(resource)
+ end
+
+ if children and ! resource.depthfirst?
+ children.each do |child|
+ events += eval_resource(child, false)
+ end
+ end
+
+ # A bit of hackery here -- if skipcheck is true, then we're the
+ # top-level resource. If that's the case, then make sure all of
+ # the changes list this resource as a proxy. This is really only
+ # necessary for rollback, since we know the generating resource
+ # during forward changes.
+ if children and checkskip
+ @changes[changecount..-1].each { |change| change.proxy = resource }
+ end
+
+ # Keep track of how long we spend in each type of resource
+ @timemetrics[resource.class.name] += seconds
+
+ events
+ end
+
# This method does all the actual work of running a transaction. It
# collects all of the changes, executes them, and responds to any
# necessary events.