diff options
| author | Luke Kanies <luke@madstop.com> | 2009-02-13 22:11:42 -0600 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-02-14 22:42:51 +1100 |
| commit | 487b9b1a3e8b9207a9910bc5eaeeb75cb3e4abe5 (patch) | |
| tree | ece8350ccecab37ef135529443e142a60259e618 | |
| parent | 610c838146c03921455a15a7a93148748ff909a6 (diff) | |
| download | puppet-487b9b1a3e8b9207a9910bc5eaeeb75cb3e4abe5.tar.gz puppet-487b9b1a3e8b9207a9910bc5eaeeb75cb3e4abe5.tar.xz puppet-487b9b1a3e8b9207a9910bc5eaeeb75cb3e4abe5.zip | |
Failure to find node facts is now a failure.
It was previously just a warning, but the node
is essentially non-functional without the facts,
so it makes more sense for it to be a warning.
Signed-off-by: Luke Kanies <luke@madstop.com>
| -rw-r--r-- | lib/puppet/node.rb | 12 | ||||
| -rwxr-xr-x | spec/unit/node.rb | 5 |
2 files changed, 13 insertions, 4 deletions
diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb index 9650562d4..74bf8902d 100644 --- a/lib/puppet/node.rb +++ b/lib/puppet/node.rb @@ -67,10 +67,14 @@ class Puppet::Node # Merge the node facts with parameters from the node source. def fact_merge - if facts = Puppet::Node::Facts.find(name) - merge(facts.values) - else - Puppet.warning "Could not find facts for %s; you probably have a discrepancy between the node and fact names" % name + begin + if facts = Puppet::Node::Facts.find(name) + merge(facts.values) + end + rescue => detail + error = Puppet::Error.new("Could not retrieve facts for %s: %s" % [name, detail]) + error.set_backtrace(detail.backtrace) + raise error end end diff --git a/spec/unit/node.rb b/spec/unit/node.rb index 25dad8c67..99c53e008 100755 --- a/spec/unit/node.rb +++ b/spec/unit/node.rb @@ -76,6 +76,11 @@ describe Puppet::Node, "when merging facts" do Puppet::Node::Facts.stubs(:find).with(@node.name).returns(Puppet::Node::Facts.new(@node.name, "one" => "c", "two" => "b")) end + it "should fail intelligently if it cannot find facts" do + Puppet::Node::Facts.expects(:find).with(@node.name).raises "foo" + lambda { @node.fact_merge }.should raise_error(Puppet::Error) + end + it "should prefer parameters already set on the node over facts from the node" do @node.parameters = {"one" => "a"} @node.fact_merge |
