one comment inlined.
On Mon, 2010-12-13 at 19:33 -0800, Andrew J. Forgue wrote:
> This patch gives Puppet the ability to find a puppet master via SRV
> records in DNS. First Puppet will try to resolve the server parameter
> in puppet.conf (or supplied on command line) to an SRV record before
> treating it as a regular host. This patch basically adds client-side
> load-balancing.
>
> Signed-off-by: Andrew J. Forgue <[email protected]>
> def find(request)
> - return nil unless result =
> deserialize(network(request).get(indirection2uri(request), headers))
> + result = nil
> +
> + Puppet::Network::Resolver.servers(request.server || self.class.server,
> request.port || self.class.port) do |server, port, remaining|
> + request.server = server
> + request.port = port
> +
> + begin
> + result = deserialize(network(request).get(indirection2uri(request),
> headers))
> + break
> + rescue SystemCallError => e
> + Puppet.warning "Error connecting to #{server}:#{port}: #{e.message}"
> + raise unless remaining > 0
> + end
> + end
> +
> + return nil unless result
I find this quite invasive (and also this code is duplicated 4 times).
Can you isolate the gory details of the "remaining" inside the Resolver
(or a method in the rest indirection), and just write the various rest
verbs as in (didn't test the code, though):
resolve(request) { |request|
result = deserialize(network(request).get(indirection2uri(request), headers))
}
with:
def resolve(request)
Puppet::Network::Resolver.servers(request.server || self.class.server,
request.port || self.class.port) do |server, port, remaining|
request.server = server
request.port = port
begin
yield request
break
rescue SystemCallError => e
Puppet.warning "Error connecting to #{server}:#{port}: #{e.message}"
raise unless remaining > 0
end
end
end
--
Brice Figureau
Follow the latest Puppet Community evolutions on www.planetpuppet.org!
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.