diff options
| author | Luke Kanies <luke@puppetlabs.com> | 2010-05-19 09:32:44 -0700 |
|---|---|---|
| committer | test branch <puppet-dev@googlegroups.com> | 2010-02-17 06:50:53 -0800 |
| commit | e9627a060619eaf0f8eeb012979dddb047c6648e (patch) | |
| tree | 697304e0850d89aad99fca266e7dcd809775992d /lib/puppet | |
| parent | 61a719f41c5448ca9ab7bdbd6a05f6c97ee80b7f (diff) | |
| download | puppet-e9627a060619eaf0f8eeb012979dddb047c6648e.tar.gz puppet-e9627a060619eaf0f8eeb012979dddb047c6648e.tar.xz puppet-e9627a060619eaf0f8eeb012979dddb047c6648e.zip | |
Fixing #2658 - adding backward compatibility for 0.24
The way stages were implemented caused backward compatibility
to be completely broken for 0.24.x.
This commit fixes that, mostly by assuming Stage[main] will be the
top node in the graph rather than Class[main].
Other stages are not supported in 0.24.x, and explicitly throw a warning
(although not an error).
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/parser/compiler.rb | 8 | ||||
| -rw-r--r-- | lib/puppet/resource.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/resource/catalog.rb | 33 | ||||
| -rw-r--r-- | lib/puppet/type.rb | 18 | ||||
| -rw-r--r-- | lib/puppet/type/stage.rb | 6 |
5 files changed, 27 insertions, 40 deletions
diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index 6cc71a62e..beba438a9 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -54,10 +54,10 @@ class Puppet::Parser::Compiler set_container_resource(scope, resource) end + # Add our container edge. If we're a class, then we get treated specially - we can + # control the stage that the class is applied in. Otherwise, we just + # get added to our parent container. def set_container_resource(scope, resource) - # Add our container edge. If we're a class, then we get treated specially - we can - # control the stage that the class is applied in. Otherwise, we just - # get added to our parent container. return if resource.type.to_s.downcase == "stage" if resource.type.to_s.downcase != "class" @@ -305,6 +305,8 @@ class Puppet::Parser::Compiler @resources << @main_resource @catalog.add_resource(@main_resource) + set_container_resource(@topscope, @main_resource) + @main_resource.evaluate end diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb index d2979f930..34d609703 100644 --- a/lib/puppet/resource.rb +++ b/lib/puppet/resource.rb @@ -267,7 +267,7 @@ class Puppet::Resource # Translate our object to a backward-compatible transportable object. def to_trans - if builtin_type? + if builtin_type? and type.downcase.to_s != "stage" result = to_transobject else result = to_transbucket diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index 3a28f45c8..a7a4b5bd0 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -33,9 +33,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph # How long this catalog took to retrieve. Used for reporting stats. attr_accessor :retrieval_duration - # How we should extract the catalog for sending to the client. - attr_reader :extraction_format - # Whether this is a host catalog, which behaves very differently. # In particular, reports are sent, graphs are made, and state is # stored in the state database. If this is set incorrectly, then you often @@ -201,33 +198,22 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph end end - # Make sure we support the requested extraction format. - def extraction_format=(value) - unless respond_to?("extract_to_%s" % value) - raise ArgumentError, "Invalid extraction format %s" % value - end - @extraction_format = value - end - - # Turn our catalog graph into whatever the client is expecting. - def extract - send("extract_to_%s" % extraction_format) - end - - # Create the traditional TransBuckets and TransObjects from our catalog - # graph. LAK:NOTE(20081211): This is a pre-0.25 backward compatibility method. + # Turn our catalog graph into an old-style tree of TransObjects and TransBuckets. + # LAK:NOTE(20081211): This is a pre-0.25 backward compatibility method. # It can be removed as soon as xmlrpc is killed. - def extract_to_transportable + def extract top = nil current = nil buckets = {} - unless main = vertices.find { |res| res.type == "Class" and res.title == :main } - raise Puppet::DevError, "Could not find 'main' class; cannot generate catalog" + unless main = resource(:stage, "main") + raise Puppet::DevError, "Could not find 'main' stage; cannot generate catalog" + end + + if stages = vertices.find_all { |v| v.type == "Stage" and v.title != "main" } and ! stages.empty? + Puppet.warning "Stages are not supported by 0.24.x client; stage(s) #{stages.collect { |s| s.to_s }.join(', ') } will be ignored" end - # Create a proc for examining edges, which we'll use to build our tree - # of TransBuckets and TransObjects. bucket = nil walk(main, :out) do |source, target| # The sources are always non-builtins. @@ -285,7 +271,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph def initialize(name = nil) super() @name = name if name - @extraction_format ||= :transportable @classes = [] @resource_table = {} @transient_resources = [] diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 7f8fb09f3..e8545413c 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -1407,24 +1407,24 @@ class Type a dependency on or from the named milestone. For instance, saying that this is in the 'bootstrap' stage creates a dependency on the 'bootstrap' milestone. - + By default, all classes get directly added to the 'main' stage. You can create new stages as resources: - + stage { [pre, post]: } - + To order stages, use standard relationships: - + stage { pre: before => Stage[main] } - + Or use the new relationship syntax: - + Stage[pre] -> Stage[main] -> Stage[post] - + Then use the new class parameters to specify a stage: - + class { foo: stage => pre } - + Stages can only be set on classes, not individual resources. This will fail:: diff --git a/lib/puppet/type/stage.rb b/lib/puppet/type/stage.rb index fba78764d..c11acdcd8 100644 --- a/lib/puppet/type/stage.rb +++ b/lib/puppet/type/stage.rb @@ -2,11 +2,11 @@ Puppet::Type.newtype(:stage) do desc "A resource type for specifying run stages. The actual stage should be specified on resources:: class { foo: stage => pre } - + And you must manually control stage order:: - + stage { pre: before => Stage[main] } - + You automatically get a 'main' stage created, and by default all resources get inserted into that stage. |
