diff options
| author | Nick Lewis <nick@puppetlabs.com> | 2011-07-21 11:47:07 -0700 |
|---|---|---|
| committer | Nick Lewis <nick@puppetlabs.com> | 2011-07-21 20:10:18 -0700 |
| commit | e2ea023f809c2bdc53b5259047c28f8061f57e54 (patch) | |
| tree | 95d2e13dc944864dd20729c53682cc052d96d160 | |
| parent | 4b0c847f19d5db81758b5561bdc8196591209ef0 (diff) | |
| download | puppet-e2ea023f809c2bdc53b5259047c28f8061f57e54.tar.gz puppet-e2ea023f809c2bdc53b5259047c28f8061f57e54.tar.xz puppet-e2ea023f809c2bdc53b5259047c28f8061f57e54.zip | |
Remove caching from the catalog, types, and parameters
Types and parameters were registering their catalog as their expirer, so that
the catalog could expire them between uses. However, because catalogs are never
reused (and neither are types or parameters), there is no need to expire
anything. Thus, we remove the entire cleanup/expire logic from catalog, type,
and parameter.
Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
| -rw-r--r-- | lib/puppet/parameter.rb | 6 | ||||
| -rw-r--r-- | lib/puppet/resource/catalog.rb | 20 | ||||
| -rw-r--r-- | lib/puppet/type.rb | 8 | ||||
| -rwxr-xr-x | spec/unit/parameter_spec.rb | 10 | ||||
| -rwxr-xr-x | spec/unit/resource/catalog_spec.rb | 25 | ||||
| -rwxr-xr-x | spec/unit/type_spec.rb | 16 |
6 files changed, 0 insertions, 85 deletions
diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb index 29d60fc66..c97f93b23 100644 --- a/lib/puppet/parameter.rb +++ b/lib/puppet/parameter.rb @@ -2,7 +2,6 @@ require 'puppet/util/methodhelper' require 'puppet/util/log_paths' require 'puppet/util/logging' require 'puppet/util/docs' -require 'puppet/util/cacher' class Puppet::Parameter include Puppet::Util @@ -10,7 +9,6 @@ class Puppet::Parameter include Puppet::Util::LogPaths include Puppet::Util::Logging include Puppet::Util::MethodHelper - include Puppet::Util::Cacher require 'puppet/parameter/value_collection' @@ -150,10 +148,6 @@ class Puppet::Parameter self.fail(Puppet::DevError, msg) end - def expirer - resource.catalog - end - def fail(*args) type = nil if args[0].is_a?(Class) diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb index 8eb4266db..bb19f3ebc 100644 --- a/lib/puppet/resource/catalog.rb +++ b/lib/puppet/resource/catalog.rb @@ -3,7 +3,6 @@ require 'puppet/indirector' require 'puppet/simple_graph' require 'puppet/transaction' -require 'puppet/util/cacher' require 'puppet/util/pson' require 'puppet/util/tagging' @@ -20,7 +19,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph include Puppet::Util::Tagging extend Puppet::Util::Pson - include Puppet::Util::Cacher::Expirer # The host name this is a catalog for. attr_accessor :name @@ -123,10 +121,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph def apply(options = {}) @applying = true - # Expire all of the resource data -- this ensures that all - # data we're operating against is entirely current. - expire - Puppet::Util::Storage.load if host_config? transaction = Puppet::Transaction.new(self, options[:report]) @@ -162,7 +156,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph return transaction ensure @applying = false - cleanup end # Are we in the middle of applying the catalog? @@ -197,14 +190,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph resource end - def dependent_data_expired?(ts) - if applying? - return super - else - return true - end - end - # 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. @@ -564,11 +549,6 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph private - def cleanup - # Expire any cached data the resources are keeping. - expire - end - # Verify that the given resource isn't defined elsewhere. def fail_on_duplicate_type_and_title(resource) # Short-curcuit the common case, diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 15f340f55..963b925bf 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -9,7 +9,6 @@ require 'puppet/metatype/manager' require 'puppet/util/errors' require 'puppet/util/log_paths' require 'puppet/util/logging' -require 'puppet/util/cacher' require 'puppet/file_collection/lookup' require 'puppet/util/tagging' @@ -21,7 +20,6 @@ class Type include Puppet::Util::Errors include Puppet::Util::LogPaths include Puppet::Util::Logging - include Puppet::Util::Cacher include Puppet::FileCollection::Lookup include Puppet::Util::Tagging @@ -469,12 +467,6 @@ class Type Puppet::Transaction::Event.new({:resource => self, :file => file, :line => line, :tags => tags}.merge(options)) end - # Let the catalog determine whether a given cached value is - # still valid or has expired. - def expirer - catalog - end - # retrieve the 'should' value for a specified property def should(name) name = attr_alias(name) diff --git a/spec/unit/parameter_spec.rb b/spec/unit/parameter_spec.rb index 04556c013..1ed211957 100755 --- a/spec/unit/parameter_spec.rb +++ b/spec/unit/parameter_spec.rb @@ -25,16 +25,6 @@ describe Puppet::Parameter do @parameter.to_s.should == @parameter.name.to_s end - it "should be able to use cached attributes" do - Puppet::Parameter.ancestors.should be_include(Puppet::Util::Cacher) - end - - it "should use the resource catalog for expiration" do - catalog = mock 'catalog' - @resource.stubs(:catalog).returns catalog - @parameter.expirer.should equal(catalog) - end - [:line, :file, :version].each do |data| it "should return its resource's #{data} as its #{data}" do @resource.expects(data).returns "foo" diff --git a/spec/unit/resource/catalog_spec.rb b/spec/unit/resource/catalog_spec.rb index 5b914dac3..c03f05dee 100755 --- a/spec/unit/resource/catalog_spec.rb +++ b/spec/unit/resource/catalog_spec.rb @@ -10,23 +10,6 @@ describe Puppet::Resource::Catalog, "when compiling" do Puppet::Util::Storage.stubs(:store) end - it "should be an Expirer" do - Puppet::Resource::Catalog.ancestors.should be_include(Puppet::Util::Cacher::Expirer) - end - - it "should always be expired if it's not applying" do - @catalog = Puppet::Resource::Catalog.new("host") - @catalog.expects(:applying?).returns false - @catalog.should be_dependent_data_expired(Time.now) - end - - it "should not be expired if it's applying and the timestamp is late enough" do - @catalog = Puppet::Resource::Catalog.new("host") - @catalog.expire - @catalog.expects(:applying?).returns true - @catalog.should_not be_dependent_data_expired(Time.now) - end - it "should be able to write its list of classes to the class file" do @catalog = Puppet::Resource::Catalog.new("host") @@ -644,11 +627,6 @@ describe Puppet::Resource::Catalog, "when compiling" do @catalog.apply(:ignoreschedules => true) end - it "should expire cached data in the resources both before and after the transaction" do - @catalog.expects(:expire).times(2) - @catalog.apply - end - describe "host catalogs" do # super() doesn't work in the setup method for some reason @@ -809,8 +787,6 @@ describe Puppet::Resource::Catalog, "when compiling" do @real_indirection = Puppet::Resource::Catalog.indirection @indirection = stub 'indirection', :name => :catalog - - Puppet::Util::Cacher.expire end it "should use the value of the 'catalog_terminus' setting to determine its terminus class" do @@ -829,7 +805,6 @@ describe Puppet::Resource::Catalog, "when compiling" do end after do - Puppet::Util::Cacher.expire @real_indirection.reset_terminus_class end end diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb index 73150af48..218c626d2 100755 --- a/spec/unit/type_spec.rb +++ b/spec/unit/type_spec.rb @@ -4,10 +4,6 @@ require 'spec_helper' describe Puppet::Type, :'fails_on_windows' => true do include PuppetSpec::Files - it "should include the Cacher module" do - Puppet::Type.ancestors.should be_include(Puppet::Util::Cacher) - end - it "should consider a parameter to be valid if it is a valid parameter" do Puppet::Type.type(:mount).should be_valid_parameter(:path) end @@ -20,18 +16,6 @@ describe Puppet::Type, :'fails_on_windows' => true do Puppet::Type.type(:mount).should be_valid_parameter(:noop) end - it "should use its catalog as its expirer" do - catalog = Puppet::Resource::Catalog.new - resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) - resource.catalog = catalog - resource.expirer.should equal(catalog) - end - - it "should do nothing when asked to expire when it has no catalog" do - resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) - lambda { resource.expire }.should_not raise_error - end - it "should be able to retrieve a property by name" do resource = Puppet::Type.type(:mount).new(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present) resource.property(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype)) |
