summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/compiler.rb
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-02-05 23:15:59 +0100
committerJames Turnbull <james@lovedthanlost.net>2009-02-14 22:32:07 +1100
commitd5abdfba8a88afda8085992a4abbe1d90bbd0084 (patch)
treea06a85798989fb25502b50c0cd2afaa347d8ad5f /lib/puppet/parser/compiler.rb
parent3fbec120768d84d208b14f574dfe916e25cfdbef (diff)
downloadpuppet-d5abdfba8a88afda8085992a4abbe1d90bbd0084.tar.gz
puppet-d5abdfba8a88afda8085992a4abbe1d90bbd0084.tar.xz
puppet-d5abdfba8a88afda8085992a4abbe1d90bbd0084.zip
Fix #1933 - Inconsistent resource evaluation order in subsequent evaluation runs
While evaluating the AST, catalog vertices are not always ordered the same way on different run, leading to some tags (which should have been applied in evaluation order) to not be associated with some underlying resources. This changeset change all accesses to resources inside the compiler to always use an ordered (in evaluation order) list of added resources. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/parser/compiler.rb')
-rw-r--r--lib/puppet/parser/compiler.rb19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb
index 9f5548d8b..7dcd50270 100644
--- a/lib/puppet/parser/compiler.rb
+++ b/lib/puppet/parser/compiler.rb
@@ -10,7 +10,7 @@ require 'puppet/util/errors'
class Puppet::Parser::Compiler
include Puppet::Util
include Puppet::Util::Errors
- attr_reader :parser, :node, :facts, :collections, :catalog, :node_scope
+ attr_reader :parser, :node, :facts, :collections, :catalog, :node_scope, :resources
# Add a collection to the global list.
def add_collection(coll)
@@ -31,6 +31,8 @@ class Puppet::Parser::Compiler
# Store a resource in our resource table.
def add_resource(scope, resource)
+ @resources << resource
+
# Note that this will fail if the resource is not unique.
@catalog.add_resource(resource)
@@ -204,11 +206,6 @@ class Puppet::Parser::Compiler
@resource_overrides[resource.ref]
end
- # Return a list of all resources.
- def resources
- @catalog.vertices
- end
-
# The top scope is usually the top-level scope, but if we're using AST nodes,
# then it is instead the node's scope.
def topscope
@@ -310,6 +307,7 @@ class Puppet::Parser::Compiler
@main_resource = Puppet::Parser::Resource.new(:type => "class", :title => :main, :scope => @topscope, :source => @main)
@topscope.resource = @main_resource
+ @resources << @main_resource
@catalog.add_resource(@main_resource)
@main_resource.evaluate
@@ -366,7 +364,7 @@ class Puppet::Parser::Compiler
# Make sure all of our resources and such have done any last work
# necessary.
def finish
- @catalog.vertices.each do |resource|
+ resources.each do |resource|
# Add in any resource overrides.
if overrides = resource_overrides(resource)
overrides.each do |over|
@@ -414,6 +412,9 @@ class Puppet::Parser::Compiler
# For maintaining the relationship between scopes and their resources.
@catalog = Puppet::Resource::Catalog.new(@node.name)
@catalog.version = @parser.version
+
+ # local resource array to maintain resource ordering
+ @resources = []
end
# Set the node's parameters into the top-scope as variables.
@@ -436,7 +437,7 @@ class Puppet::Parser::Compiler
# We used to have hooks here for forking and saving, but I don't
# think it's worth retaining at this point.
- store_to_active_record(@node, @catalog.vertices)
+ store_to_active_record(@node, resources)
end
# Do the actual storage.
@@ -459,7 +460,7 @@ class Puppet::Parser::Compiler
# Return an array of all of the unevaluated resources. These will be definitions,
# which need to get evaluated into native resources.
def unevaluated_resources
- ary = @catalog.vertices.reject { |resource| resource.builtin? or resource.evaluated? }
+ ary = resources.reject { |resource| resource.builtin? or resource.evaluated? }
if ary.empty?
return nil