Commit ffc5d879 authored by ale's avatar ale

Have the client retry on temporary network errors

parent d21e2d6b
Pipeline #4803 passed with stages
in 2 minutes and 19 seconds
......@@ -2,8 +2,11 @@ package client
import (
......@@ -26,6 +29,23 @@ func New(socketPath string) Client {
func (c *socketClient) Authenticate(ctx context.Context, req *auth.Request) (*auth.Response, error) {
// Retry the request, with backoff, if we get a temporary
// network error.
var resp *auth.Response
err := backoff.Retry(func() error {
var err error
resp, err = c.doAuthenticate(ctx, req)
if err == nil {
return nil
} else if netErr, ok := err.(net.Error); ok && netErr.Temporary() {
return netErr
return backoff.Permanent(err)
}, backoff.WithContext(backoff.NewExponentialBackOff(), ctx))
return resp, err
func (c *socketClient) doAuthenticate(ctx context.Context, req *auth.Request) (*auth.Response, error) {
// Create the connection outside of the timed goroutine, so
// that we can call Close() on exit regardless of the reason:
// this way, when a timeout occurs or the context is canceled,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment