-
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
Use first available auth server #11229
Conversation
s := NewAuthProxyDialerService(nil, mockAuthGetter{servers: []types.Server{server1}}) | ||
_, err = s.dialLocalAuthServer(context.Background()) | ||
require.Error(t, err) | ||
require.Equal(t, "all auth servers unavailable: invalid:8000: dial tcp: lookup invalid: no such host", err.Error()) |
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.
CI disagrees with this exact error; a bit of a moot point if you might change the error anyway, but I'd be a little lax on the exact error message - something along the lines of require.Contains(t, "all auth servers unavailable: invalid:8000", err.Error())
would be better.
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.
+1
servers = append(servers, server) | ||
} | ||
s := NewAuthProxyDialerService(nil, mockAuthGetter{servers: servers}) | ||
_, err = s.dialLocalAuthServer(context.Background()) |
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.
Won't this block indefinitely, because you're not actually accepting connections on your listener? Either way, pass a context with a timeout here.
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.
+1 for a short timeout
lib/srv/alpnproxy/auth/auth_proxy.go
Outdated
authServerIndex := rand.Intn(len(authServers)) | ||
var conn net.Conn | ||
addr := authServers[authServerIndex].GetAddr() | ||
conn, err = net.Dial("tcp", addr) |
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.
While we're touching this:
conn, err = net.Dial("tcp", addr) | |
var d net.Dialer | |
conn, err = d.DialContext(ctx, "tcp", addr) |
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.
Overall seems reasonable to me.
s := NewAuthProxyDialerService(nil, mockAuthGetter{servers: []types.Server{server1}}) | ||
_, err = s.dialLocalAuthServer(context.Background()) | ||
require.Error(t, err) | ||
require.Equal(t, "all auth servers unavailable: invalid:8000: dial tcp: lookup invalid: no such host", err.Error()) |
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.
+1
servers = append(servers, server) | ||
} | ||
s := NewAuthProxyDialerService(nil, mockAuthGetter{servers: servers}) | ||
_, err = s.dialLocalAuthServer(context.Background()) |
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.
+1 for a short timeout
Co-authored-by: Edoardo Spadolini <[email protected]>
Currently we use random auth server from the list but if it's unavailable (for example it was restarted but there's still entry in cache, dynamodb backend etc) we return error. This change tries all servers (in random order) and uses first that is available. Closes #10019 (cherry picked from commit 35a9bbc)
Currently we use random auth server from the list but if it's unavailable (for example it was restarted but there's still entry in cache, dynamodb backend etc) we return error. This change tries all servers (in random order) and uses first that is available. Closes #10019 (cherry picked from commit 35a9bbc)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Currently we use random auth server from the list but if it's unavailable (for example it was restarted but there's still entry in cache, dynamodb backend etc) we return error. This change tries all servers (in random order) and uses first that is available. Closes #10019 (cherry picked from commit 35a9bbc)
Currently we use random auth server from the list but if it's unavailable (for example it was restarted but there's still entry in cache, dynamodb backend etc) we return error. This change tries all servers (in random order) and uses first that is available. Closes #10019 (cherry picked from commit 35a9bbc)
Currently we use random auth server from the list but if it's unavailable (for example it was restarted but there's still entry in cache, dynamodb backend etc) we return error.
This change tries all servers (in random order) and uses first that is available.
Closes #10019