Skip to content

Commit 2e24fb7

Browse files
committed
(PUP-9076) Do not push nil on server context
and fail if none of the servers in `server_list` are reachable
1 parent 5efd824 commit 2e24fb7

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

lib/puppet/configurer.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,7 @@ def run(options = {})
222222
found = find_functional_server()
223223
server = found[:server]
224224
if server.nil?
225-
Puppet.warning _("Could not select a functional puppet master")
226-
server = [nil, nil]
225+
raise Puppet::Error, _("Could not select a functional puppet master from server_list: '%{server_list}'") % { server_list: Puppet.settings[:server_list] }
227226
end
228227
Puppet.override(:server => server[0], :serverport => server[1]) do
229228
if !server.first.nil?

spec/unit/configurer_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,17 +1027,15 @@ def expects_neither_new_or_cached_catalog
10271027
@agent.run
10281028
end
10291029

1030-
it "should fallback to an empty server when failover fails" do
1030+
it "should error when no servers in 'server_list' are reachable" do
10311031
Puppet.settings[:server_list] = ["myserver:123"]
10321032
pool = Puppet::Network::HTTP::Pool.new(Puppet[:http_keepalive_timeout])
10331033
Puppet::Network::HTTP::Pool.expects(:new).returns(pool)
10341034
Puppet.expects(:override).with({:http_pool => pool}).yields
10351035
Puppet.expects(:override).with({:server => "myserver", :serverport => '123'}).yields
1036-
Puppet.expects(:override).with({:server => nil, :serverport => nil}).yields
10371036
error = Net::HTTPError.new(400, 'dummy server communication error')
10381037
Puppet::Node.indirection.expects(:find).raises(error)
1039-
@agent.expects(:run_internal).returns(nil)
1040-
@agent.run
1038+
expect{ @agent.run }.to raise_error(Puppet::Error, /Could not select a functional puppet master from server_list/)
10411039
end
10421040

10431041
it "should not make multiple node requets when the server is found" do

0 commit comments

Comments
 (0)