summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/configurer/fact_handler.rb7
-rw-r--r--lib/puppet/indirector/catalog/compiler.rb8
-rwxr-xr-xspec/unit/configurer/fact_handler.rb12
-rwxr-xr-xspec/unit/indirector/catalog/compiler.rb5
4 files changed, 30 insertions, 2 deletions
diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb
index d0e890f62..8a6de5e9f 100644
--- a/lib/puppet/configurer/fact_handler.rb
+++ b/lib/puppet/configurer/fact_handler.rb
@@ -18,7 +18,12 @@ module Puppet::Configurer::FactHandler
# This works because puppetd configures Facts to use 'facter' for
# finding facts and the 'rest' terminus for caching them. Thus, we'll
# compile them and then "cache" them on the server.
- Puppet::Node::Facts.find(Puppet[:certname])
+ begin
+ Puppet::Node::Facts.find(Puppet[:certname])
+ rescue => detail
+ puts detail.backtrace if Puppet[:trace]
+ Puppet.err("Could not retrieve local facts: %s" % detail)
+ end
end
# Retrieve facts from the central server.
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb
index 83b636433..47635d88c 100644
--- a/lib/puppet/indirector/catalog/compiler.rb
+++ b/lib/puppet/indirector/catalog/compiler.rb
@@ -88,7 +88,13 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
# Turn our host name into a node object.
def find_node(name)
- return nil unless node = Puppet::Node.find(name)
+ begin
+ return nil unless node = Puppet::Node.find(name)
+ rescue => detail
+ puts detail.backtrace if Puppet[:trace]
+ raise Puppet::Error, "Failed when searching for node %s: %s" % [name, detail]
+ end
+
# Add any external data to the node.
add_node_data(node)
diff --git a/spec/unit/configurer/fact_handler.rb b/spec/unit/configurer/fact_handler.rb
index 7973d0532..43f6e4f60 100755
--- a/spec/unit/configurer/fact_handler.rb
+++ b/spec/unit/configurer/fact_handler.rb
@@ -65,6 +65,18 @@ describe Puppet::Configurer::FactHandler do
@facthandler.upload_facts
end
+ it "should not fail if uploading facts fails" do
+ @facthandler.stubs(:reload_facter)
+
+ Puppet.settings.stubs(:value).with(:trace).returns false
+ Puppet.settings.stubs(:value).with(:certname).returns "myhost"
+ Puppet::Node::Facts.expects(:find).raises RuntimeError
+
+ Puppet.expects(:err)
+
+ lambda { @facthandler.upload_facts }.should_not raise_error
+ end
+
describe "when reloading Facter" do
before do
Facter.stubs(:clear)
diff --git a/spec/unit/indirector/catalog/compiler.rb b/spec/unit/indirector/catalog/compiler.rb
index 6d1dc761c..5518169b1 100755
--- a/spec/unit/indirector/catalog/compiler.rb
+++ b/spec/unit/indirector/catalog/compiler.rb
@@ -98,6 +98,11 @@ describe Puppet::Resource::Catalog::Compiler do
proc { @compiler.find(@request) }.should raise_error(ArgumentError)
end
+ it "should fail intelligently when searching for a node raises an exception" do
+ Puppet::Node.stubs(:find).with(@name).raises "eh"
+ proc { @compiler.find(@request) }.should raise_error(Puppet::Error)
+ end
+
it "should pass the found node to the interpreter for compiling" do
Puppet::Node.expects(:find).with(@name).returns(@node)
config = mock 'config'