summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@reductivelabs.com>2010-03-25 14:55:51 -0700
committerJames Turnbull <james@lovedthanlost.net>2010-03-27 14:32:07 +1100
commit7018cf5634bcbdcc167d5fbe5560801a2a131ca9 (patch)
tree140ad6afb19c3f23cb92f5b234ac6694af0ed288
parent978ab8a9a1f1c7ea23698543bf86f587ae88e6c4 (diff)
downloadpuppet-7018cf5634bcbdcc167d5fbe5560801a2a131ca9.tar.gz
puppet-7018cf5634bcbdcc167d5fbe5560801a2a131ca9.tar.xz
puppet-7018cf5634bcbdcc167d5fbe5560801a2a131ca9.zip
Adding :catalog_terminus setting
This will rarely be used, but it enables even more architectural flexibility, such as precompiling catalogs and storing them in memcached or equivalent. With this setup, a single host can probably serve all catalogs and you would then just have as many compiling hosts as needed. Signed-off-by: Luke Kanies <luke@reductivelabs.com>
-rw-r--r--lib/puppet/application/puppetd.rb5
-rw-r--r--lib/puppet/configurer.rb12
-rw-r--r--lib/puppet/defaults.rb2
-rw-r--r--lib/puppet/resource/catalog.rb2
-rwxr-xr-xspec/unit/application/puppetd.rb5
-rwxr-xr-xspec/unit/configurer.rb32
-rwxr-xr-xspec/unit/resource/catalog.rb10
7 files changed, 50 insertions, 18 deletions
diff --git a/lib/puppet/application/puppetd.rb b/lib/puppet/application/puppetd.rb
index fe111867d..8b07c90dd 100644
--- a/lib/puppet/application/puppetd.rb
+++ b/lib/puppet/application/puppetd.rb
@@ -211,7 +211,10 @@ Puppet::Application.new(:puppetd) do
Puppet::Transaction::Report.terminus_class = :rest
- Puppet::Resource::Catalog.terminus_class = :rest
+ # Override the default; puppetd needs this, usually.
+ # You can still override this on the command-line with, e.g., :compiler.
+ Puppet[:catalog_terminus] = :rest
+
Puppet::Resource::Catalog.cache_class = :yaml
Puppet::Node::Facts.terminus_class = :facter
diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb
index dc110dc9e..6aeac7486 100644
--- a/lib/puppet/configurer.rb
+++ b/lib/puppet/configurer.rb
@@ -91,10 +91,14 @@ class Puppet::Configurer
# Get the remote catalog, yo. Returns nil if no catalog can be found.
def retrieve_catalog
- # This is a bit complicated. We need the serialized and escaped facts,
- # and we need to know which format they're encoded in. Thus, we
- # get a hash with both of these pieces of information.
- fact_options = facts_for_uploading()
+ if Puppet::Resource::Catalog.indirection.terminus_class == :rest
+ # This is a bit complicated. We need the serialized and escaped facts,
+ # and we need to know which format they're encoded in. Thus, we
+ # get a hash with both of these pieces of information.
+ fact_options = facts_for_uploading()
+ else
+ fact_options = {}
+ end
# First try it with no cache, then with the cache.
unless (Puppet[:use_cached_catalog] and result = retrieve_catalog_from_cache(fact_options)) or result = retrieve_new_catalog(fact_options)
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 7e4c51703..5901d1983 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -149,6 +149,8 @@ module Puppet
huge numbers that can then not be fed back into the system. This is a hackish way to fail in a
slightly more useful way when that happens."],
:node_terminus => ["plain", "Where to find information about nodes."],
+ :catalog_terminus => ["compiler", "Where to get node catalogs. This is useful to change if, for instance,
+ you'd like to pre-compile catalogs and store them in memcached or some other easily-accessed store."],
:httplog => { :default => "$logdir/http.log",
:owner => "root",
:mode => 0640,
diff --git a/lib/puppet/resource/catalog.rb b/lib/puppet/resource/catalog.rb
index f21c820a0..f49c95540 100644
--- a/lib/puppet/resource/catalog.rb
+++ b/lib/puppet/resource/catalog.rb
@@ -16,7 +16,7 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
class DuplicateResourceError < Puppet::Error; end
extend Puppet::Indirector
- indirects :catalog, :terminus_class => :compiler
+ indirects :catalog, :terminus_setting => :catalog_terminus
include Puppet::Util::Tagging
extend Puppet::Util::Pson
diff --git a/spec/unit/application/puppetd.rb b/spec/unit/application/puppetd.rb
index ec2fd546d..0f7257e59 100755
--- a/spec/unit/application/puppetd.rb
+++ b/spec/unit/application/puppetd.rb
@@ -301,9 +301,8 @@ describe "puppetd" do
@puppetd.run_setup
end
- it "should tell the catalog handler to use REST" do
- Puppet::Resource::Catalog.expects(:terminus_class=).with(:rest)
-
+ it "should change the catalog_terminus setting to 'rest'" do
+ Puppet.expects(:[]=).with(:catalog_terminus, :rest)
@puppetd.run_setup
end
diff --git a/spec/unit/configurer.rb b/spec/unit/configurer.rb
index 4439f3223..df58d5b7e 100755
--- a/spec/unit/configurer.rb
+++ b/spec/unit/configurer.rb
@@ -141,6 +141,9 @@ describe Puppet::Configurer, "when retrieving a catalog" do
@catalog = Puppet::Resource::Catalog.new
+ # this is the default when using a Configurer instance
+ Puppet::Resource::Catalog.indirection.stubs(:terminus_class).returns :rest
+
@agent.stubs(:convert_catalog).returns @catalog
end
@@ -164,6 +167,28 @@ describe Puppet::Configurer, "when retrieving a catalog" do
end
end
+ describe "when not using a REST terminus for catalogs" do
+ it "should not pass any facts when retrieving the catalog" do
+ @agent.expects(:facts_for_uploading).never
+ Puppet::Resource::Catalog.expects(:find).with { |name, options|
+ options[:facts].nil?
+ }.returns @catalog
+
+ @agent.retrieve_catalog
+ end
+ end
+
+ describe "when using a REST terminus for catalogs" do
+ it "should pass the prepared facts and the facts format as arguments when retrieving the catalog" do
+ @agent.expects(:facts_for_uploading).returns(:facts => "myfacts", :facts_format => :foo)
+ Puppet::Resource::Catalog.expects(:find).with { |name, options|
+ options[:facts] == "myfacts" and options[:facts_format] == :foo
+ }.returns @catalog
+
+ @agent.retrieve_catalog
+ end
+ end
+
it "should use the Catalog class to get its catalog" do
Puppet::Resource::Catalog.expects(:find).returns @catalog
@@ -178,13 +203,6 @@ describe Puppet::Configurer, "when retrieving a catalog" do
@agent.retrieve_catalog
end
- it "should pass the prepared facts and the facts format as arguments when retrieving the catalog" do
- @agent.expects(:facts_for_uploading).returns(:facts => "myfacts", :facts_format => :foo)
- Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:facts] == "myfacts" and options[:facts_format] == :foo }.returns @catalog
-
- @agent.retrieve_catalog
- end
-
it "should default to returning a catalog retrieved directly from the server, skipping the cache" do
Puppet::Resource::Catalog.expects(:find).with { |name, options| options[:ignore_cache] == true }.returns @catalog
diff --git a/spec/unit/resource/catalog.rb b/spec/unit/resource/catalog.rb
index db672438d..ab6aa68be 100755
--- a/spec/unit/resource/catalog.rb
+++ b/spec/unit/resource/catalog.rb
@@ -843,8 +843,14 @@ describe Puppet::Resource::Catalog, "when compiling" do
Puppet::Resource::Catalog.find(:myconfig)
end
- it "should default to the 'compiler' terminus" do
- Puppet::Resource::Catalog.indirection.terminus_class.should == :compiler
+ it "should use the value of the 'catalog_terminus' setting to determine its terminus class" do
+ Puppet.settings[:catalog_terminus] = "rest"
+ Puppet::Resource::Catalog.indirection.terminus_class.should == :rest
+ end
+
+ it "should allow the terminus class to be set manually" do
+ Puppet::Resource::Catalog.indirection.terminus_class = :rest
+ Puppet::Resource::Catalog.indirection.terminus_class.should == :rest
end
after do