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
Retry SSH resolution 5 times #2934
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.
👋 @stanhu! Thanks for getting this started. Your initial patch looks good to me, and I have left a few review comments for your consideration.
With respect to filling a value for maxSshAuthenticateRetries
, an example of how to do this is here:
Lines 75 to 78 in 98288ae
if git := apiClient.GitEnv(); git != nil { | |
if v := git.Int("lfs.transfer.maxretries", 0); v > 0 { | |
m.maxRetries = v | |
} |
lfsapi/client.go
Outdated
httpRE = regexp.MustCompile(`\Ahttps?://`) | ||
UserAgent = "git-lfs" | ||
httpRE = regexp.MustCompile(`\Ahttps?://`) | ||
maxSshAuthenticateRetries = 5 |
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.
Do you think that this could be an instance variable belonging to *lfsapi.Client
? I don't think that this has to be in the package-global namespace, so I'd advocate for the former.
lfsapi/client.go
Outdated
if err == nil { | ||
return sshRes, nil | ||
} | ||
|
||
tracerx.Printf("ssh: %s failed, error: %s, message: %s", |
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.
Should these messages be changed to indicate when we are and aren't retrying? You can take a look at something similar, like this:
Line 493 in 8c8a711
tracerx.Printf("tq: enqueue retry #%d for %q (size: %d): %s", count, tr.Oid, tr.Size, err) |
lfsapi/client.go
Outdated
func (c *Client) NewRequest(method string, e Endpoint, suffix string, body interface{}) (*http.Request, error) { | ||
sshRes, err := c.SSH.Resolve(e, method) | ||
if err != nil { | ||
func (c *Client) sshResolveWithRetries(e Endpoint, method string) (sshAuthResponse, 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.
What do you think about changing the return type of this method to be:
(*sshAuthResponse, error)
instead of
(sshAuthResponse, error)
that way we can return nil
to indicate a failure or missing sshAuthResponse
, instead of sshAuthResponse{}
, which could be misleading or confusing to callers of this method.
lfsapi/client.go
Outdated
for i := 0; i < requests; i++ { | ||
sshRes, err = c.SSH.Resolve(e, method) | ||
if err == nil { | ||
return sshRes, nil |
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.
Per my suggestion above, this line would change to:
return &sshRes, nil
lfsapi/client.go
Outdated
return nil, errors.Wrap(err, sshRes.Message) | ||
} | ||
if len(sshRes.Message) > 0 { | ||
return sshAuthResponse{}, errors.Wrap(err, sshRes.Message) |
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.
And this, (as well as the line below it, L51) would change to:
return nil, err
Hi @stanhu, I hope that it's OK I updated your branch myself to include feedback that I gave above and changes from master. |
@ttaylorr Thanks! |
Closes #2914