[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.4-89-gcbbd363

James Turnbull james at lovedthanlost.net
Tue May 18 09:04:13 UTC 2010


The following commit has been merged in the upstream branch:
commit 6d13d0d0b2617100488f9eccc0bbee0ba934d624
Author: Luke Kanies <luke at reductivelabs.com>
Date:   Wed Mar 24 00:04:47 2010 -0700

    Adding support for only using cached catalogs
    
    This basically allows a sysadmin to control when a client
    will compile a new catalog - with this option enabled,
    the client will use the cached catalog as long as it has
    one, only recompiling when run with the option disabled.
    
    Signed-off-by: Luke Kanies <luke at reductivelabs.com>

diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb
index f815776..dc110dc 100644
--- a/lib/puppet/configurer.rb
+++ b/lib/puppet/configurer.rb
@@ -97,7 +97,7 @@ class Puppet::Configurer
         fact_options = facts_for_uploading()
 
         # First try it with no cache, then with the cache.
-        unless result = retrieve_new_catalog(fact_options)
+        unless (Puppet[:use_cached_catalog] and result = retrieve_catalog_from_cache(fact_options)) or result = retrieve_new_catalog(fact_options)
             if ! Puppet[:usecacheonfailure]
                 Puppet.warning "Not using cache on failed catalog"
                 return nil
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index d4a5a18..7e4c517 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -556,6 +556,10 @@ module Puppet
             new configurations, where you want to fix the broken configuration
             rather than reverting to a known-good one."
         ],
+        :use_cached_catalog => [false,
+            "Whether to only use the cached catalog rather than compiling a new catalog
+            on every run.  Puppet can be run with this enabled by default and then selectively
+            disabled when a recompile is desired."],
         :ignorecache => [false,
             "Ignore cache and always recompile the configuration.  This is
             useful for testing new configurations, where the local cache may in
diff --git a/spec/unit/configurer.rb b/spec/unit/configurer.rb
index 32c0772..4439f32 100755
--- a/spec/unit/configurer.rb
+++ b/spec/unit/configurer.rb
@@ -144,6 +144,26 @@ describe Puppet::Configurer, "when retrieving a catalog" do
         @agent.stubs(:convert_catalog).returns @catalog
     end
 
+    describe "and configured to only retrieve a catalog from the cache" do
+        before do
+            Puppet.settings[:use_cached_catalog] = true
+        end
+
+        it "should first look in the cache for a catalog" do
+            Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns @catalog
+            Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.never
+
+            @agent.retrieve_catalog.should == @catalog
+        end
+
+        it "should compile a new catalog if none is found in the cache" do
+            Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_terminus] == true }.returns nil
+            Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns @catalog
+
+            @agent.retrieve_catalog.should == @catalog
+        end
+    end
+
     it "should use the Catalog class to get its catalog" do
         Puppet::Resource::Catalog.expects(:find).returns @catalog
 
@@ -152,7 +172,7 @@ describe Puppet::Configurer, "when retrieving a catalog" do
 
     it "should use its certname to retrieve the catalog" do
         Facter.stubs(:value).returns "eh"
-        Puppet.expects(:[]).with(:certname).returns "myhost.domain.com"
+        Puppet.settings[:certname] = "myhost.domain.com"
         Puppet::Resource::Catalog.expects(:find).with { |name, options| name == "myhost.domain.com" }.returns @catalog
 
         @agent.retrieve_catalog

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list