-
Notifications
You must be signed in to change notification settings - Fork 2.2k
(PUP-10039) Add ServerList resolver #7856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(PUP-10039) Add ServerList resolver #7856
Conversation
CLA signed by all contributors. |
ea5c6f5
to
e499363
Compare
end | ||
end | ||
|
||
errors.each { |e| Puppet.log_exception(e) } | ||
|
||
@resolution_exceptions.each { |e| Puppet.log_exception(e) } | ||
raise Puppet::HTTP::RouteError, "No more routes to #{name}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mucked with the code to play with this a bit more:
I added the ServerList resolver to the CA service, and I removed the raise
in the ServerList resolver so that we would fall back to the settings resolver. I also ensured both the SRV and ServerList resolvers return nil
if we don't find anything that connects successfully (otherwise we get weird errors when it tries to resolve service.url
on line 20, since service
is being set to either the array of servers in server_list
or an empty array for srv).
be ./bin/puppet agent -t --server_list apple.example.com,google.example.com --use_srv_records --debug
Debug: Resolving service 'ca' using Puppet::HTTP::Resolver::ServerList
Debug: Creating new connection for https://apple.example.com:8140
Debug: Starting connection for https://apple.example.com:8140
Debug: Unable to connect to server from server_list setting: Failed to connect to https://apple.example.com:8140/status/v1/simple/master: Failed to open TCP connection to apple.example.com:8140 (getaddrinfo: nodename nor servname provided, or not known)
Debug: Creating new connection for https://google.example.com:8140
Debug: Starting connection for https://google.example.com:8140
Debug: Unable to connect to server from server_list setting: Failed to connect to https://google.example.com:8140/status/v1/simple/master: Failed to open TCP connection to google.example.com:8140 (getaddrinfo: nodename nor servname provided, or not known)
Debug: Resolving service 'ca' using Puppet::HTTP::Resolver::SRV
Debug: Searching for SRV records for domain: Home
Debug: Found 0 SRV records for: _x-puppet-ca._tcp.Home
Debug: Searching for SRV records for domain: Home
Debug: Found 0 SRV records for: _x-puppet._tcp.Home
Debug: Resolving service 'ca' using Puppet::HTTP::Resolver::Settings
Debug: Creating new connection for https://puppet:8140
Debug: Starting connection for https://puppet:8140
Debug: Connection to https://puppet:8140/puppet-ca/v1 failed, trying next route: Failed to connect to https://puppet:8140/puppet-ca/v1: execution expired
Error: Failed to connect to https://apple.example.com:8140/status/v1/simple/master: Failed to open TCP connection to apple.example.com:8140 (getaddrinfo: nodename nor servname provided, or not known)
Wrapped exception:
Failed to open TCP connection to apple.example.com:8140 (getaddrinfo: nodename nor servname provided, or not known)
Error: Failed to connect to https://google.example.com:8140/status/v1/simple/master: Failed to open TCP connection to google.example.com:8140 (getaddrinfo: nodename nor servname provided, or not known)
Wrapped exception:
Failed to open TCP connection to google.example.com:8140 (getaddrinfo: nodename nor servname provided, or not known)
Error: Failed to connect to https://puppet:8140/puppet-ca/v1: execution expired
Wrapped exception:
execution expired
Error: No more routes to ca
Error: Could not run: No more routes to ca
9a10d86
to
6e6b012
Compare
@joshcooper I think I addressed all of your comments. I switched this to a real PR from a draft. I think it's ready to go. |
b9aeefc
to
c5654ad
Compare
This commit adds a resolver that will iterate through an array of servers and return the first in the list that responds successfully to a get connection. We do not yet use this new resolver anywhere, but will switch over to it in the near future. If a port is not provided in the list of servers, it will use a default port. If no functional server is found, we raise an error rather than allowing the session to continue searching other resolvers for a functional server.
Rather than checking a connection is successful as a part of the session, this commit changes to let us check that connection in the resolvers. This is something we needed to do for ServerList, so this change makes that behavior consistent for all other resolvers as well. It also allows us to reduce some complexity. We can now create the service directly from the resolver, rather than having to pass that call down from the resolver, to the session, and finally to the service.
Rather than have both service doubles named the same thing, we need to be able to distinguish them. This way, if something gets messed up and the tests fail, both the name and the object id will be different. They won't look like the same object at first glance.
c5654ad
to
a139ae8
Compare
No description provided.