vendored/puppet/lib/puppet/indirector/request.rb in bolt-0.20.3 vs vendored/puppet/lib/puppet/indirector/request.rb in bolt-0.20.5
- old
+ new
@@ -183,11 +183,15 @@
# This happens if someone does something like specifying a file
# source using a puppet:// URI with a specific server.
return yield(self) if !self.server.nil?
if Puppet.settings[:use_srv_records]
- Puppet::Network::Resolver.each_srv_record(Puppet.settings[:srv_domain], srv_service) do |srv_server, srv_port|
+ # We may want to consider not creating a new resolver here
+ # every request eventually, to take advantage of the resolver's
+ # caching behavior.
+ resolver = Puppet::Network::Resolver.new
+ resolver.each_srv_record(Puppet.settings[:srv_domain], srv_service) do |srv_server, srv_port|
begin
self.server = srv_server
self.port = srv_port
return yield(self)
rescue SystemCallError => e
@@ -195,26 +199,22 @@
end
end
end
# ... Fall back onto the default server.
- begin
- bound_server = Puppet.lookup(:server)
- rescue
+ bound_server = Puppet.lookup(:server) do
if primary_server = Puppet.settings[:server_list][0]
- bound_server = primary_server[0]
+ primary_server[0]
else
- bound_server = Puppet.settings[:server]
+ Puppet.settings[:server]
end
end
- begin
- bound_port = Puppet.lookup(:serverport)
- rescue
+ bound_port = Puppet.lookup(:serverport) do
if primary_server = Puppet.settings[:server_list][0]
- bound_port = primary_server[1]
+ primary_server[1]
else
- bound_port = Puppet.settings[:masterport]
+ Puppet.settings[:masterport]
end
end
self.server = default_server || bound_server
self.port = default_port || bound_port