-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
API client connection overhaul #5625
Conversation
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.
Please also manually test that dialing auth directly and via a proxy works
a0419a8
to
1bcaa55
Compare
ccad89f
to
556f49c
Compare
8c868d1
to
521d83f
Compare
22f6534
to
d8ca29a
Compare
390ac2c
to
9b36d55
Compare
… comment; Add nonblocking NewTLSAuthClient function for use in teleport libraries.
…urrent connection logic; Refactor lib/auth/clt.Client implementation to decouple the http client into its own struct.
9b36d55
to
1259daf
Compare
…eleport into joerger/api-proxy-dialer
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.
A couple of minor remarks.
api/client/credentials.go
Outdated
if err != nil { | ||
return nil, trace.Wrap(err) | ||
} | ||
|
||
return configure(tlsConfig), nil | ||
} | ||
|
||
// SSHClientConfig returns SSH configuration used to connect to Proxy. | ||
func (c *IdentityCreds) SSHClientConfig() (*ssh.ClientConfig, error) { | ||
identityFile, err := ReadIdentityFile(c.path) |
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.
Is there a disadvantage to doing
type IdentityCreds struct {
identityFile *IdentityFile
}
(or similar) right away?
@russjones ready for bot. |
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.
Bot.
* Added support for connecting API client through tunnel proxy and web proxy addresses (with identity file). * Added concurrent dialing logic to dial several possible dialing combinations and seamlessly return the first client to connect.
* Added support for connecting API client through tunnel proxy and web proxy addresses (with identity file). * Added concurrent dialing logic to dial several possible dialing combinations and seamlessly return the first client to connect.
This PR adds support for connecting client through proxy tunnel address and web proxy address, and fixes client initialization performance issues with concurrent connection attempts. A lot of code had to be moved around to enable proxy dialing while maintaining a very small go module in
client/api
.Changes:
NewTunnelDialer
function to create an ssh tunnel dialer for the client.SSHConfig
method to Credentials, onlyIdentityCreds
implements it fully.PublicTunnelAddr
from web proxy infindTunnelAddr()
.contextdialer.go
,ssh.go
, andchconn.go
in theapi/client
package, and refactor moved code to reduce imports.Key
methods toapi/utils/ssh.go
to be reused byIdentityFile
.LoadIdentity
fromtsh/common
tolib/client/interfaces.go
asKeyFromIdentityFile
. Moved logic specific to actually loading the identityFile toReadIdentityFile
.connect
function to enable synchronous logic and improve separation of concerns.To expand on the client initialization performance issue, the client takes a list of Credentials and a list of Addresses to connect the client to a server. The addresses can be web proxy, tunnel proxy, or auth server addresses. So each Credential+Address combination has to be dialed as each type of address, leading to 3nm performance where n is # of addrs and m is # of creds. In practice, both n and m should be low, but with a default dial timeout of 30 seconds, it quickly become unusable. Given the way the grpc dialer behaves, there isn't a good way (that I could come up with) to handle these combinations without dialing each one and testing the connection one my one. This led me to the solution of concurrently trying all combinations, which quickly hones in on a connection. I'm very open to other solution ideas as this feels a bit overly complicated for a normal API client.