Skip to content

(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

Conversation

melissa
Copy link
Contributor

@melissa melissa commented Nov 22, 2019

No description provided.

@puppetcla
Copy link

CLA signed by all contributors.

@melissa melissa force-pushed the ticket/master/pup-10039-serverlist-resolver branch 4 times, most recently from ea5c6f5 to e499363 Compare November 26, 2019 23:53
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}"
Copy link
Contributor Author

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

@melissa melissa force-pushed the ticket/master/pup-10039-serverlist-resolver branch 2 times, most recently from 9a10d86 to 6e6b012 Compare December 2, 2019 21:40
@melissa melissa marked this pull request as ready for review December 2, 2019 21:40
@melissa melissa requested a review from a team December 2, 2019 21:40
@melissa
Copy link
Contributor Author

melissa commented Dec 2, 2019

@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.

@melissa melissa changed the title Ticket/master/pup 10039 serverlist resolver (PUP-10039) Add ServerList resolver Dec 2, 2019
@melissa melissa force-pushed the ticket/master/pup-10039-serverlist-resolver branch from b9aeefc to c5654ad Compare December 2, 2019 21:58
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.
@melissa melissa force-pushed the ticket/master/pup-10039-serverlist-resolver branch from c5654ad to a139ae8 Compare December 3, 2019 01:46
@joshcooper joshcooper merged commit e4a4812 into puppetlabs:master Dec 3, 2019
@melissa melissa deleted the ticket/master/pup-10039-serverlist-resolver branch March 25, 2020 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants