Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/puppet/configurer/fact_handler.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require_relative '../../puppet/agent'
require_relative '../../puppet/indirector/facts/facter'

require_relative '../../puppet/configurer'
Expand All @@ -20,7 +21,10 @@ def find_facts
facts.name = Puppet[:node_name_value]
end
facts
rescue SystemExit, NoMemoryError
rescue SystemExit, NoMemoryError, Puppet::Agent::RunTimeoutError
# RunTimeoutError means the agent run as a whole has exceeded `runtimeout`.
# Let it propagate so the run is aborted instead of wrapping it in a
# Puppet::Error and carrying on with the rest of the run.
raise
rescue Exception => detail
message = _("Could not retrieve local facts: %{detail}") % { detail: detail }
Expand Down
7 changes: 7 additions & 0 deletions spec/unit/configurer/fact_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ def reload_facter
expect { facthandler.find_facts }.to raise_error(Puppet::Error, /Could not retrieve local facts/)
end

it "should re-raise RunTimeoutError so the agent run is aborted" do
expect(Puppet::Node::Facts.indirection).to receive(:find).and_raise(Puppet::Agent::RunTimeoutError, 'execution expired')
expect(Puppet).not_to receive(:log_exception)

expect { facthandler.find_facts }.to raise_error(Puppet::Agent::RunTimeoutError, 'execution expired')
end

it "should only load fact plugins once" do
expect(Puppet::Node::Facts.indirection).to receive(:find).once
facthandler.find_facts
Expand Down