Skip to content
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

Merged
merged 7 commits into from Jul 6, 2018
Merged

Conversation

stanhu
Copy link
Contributor

@stanhu stanhu commented Mar 21, 2018

Closes #2914

Copy link
Contributor

@ttaylorr ttaylorr left a 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:

git-lfs/tq/manifest.go

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
Copy link
Contributor

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",
Copy link
Contributor

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:

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) {
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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

@ttaylorr ttaylorr changed the title WIP: Retry SSH resolution 5 times Retry SSH resolution 5 times Jun 28, 2018
@ttaylorr
Copy link
Contributor

Hi @stanhu, I hope that it's OK I updated your branch myself to include feedback that I gave above and changes from master.

@stanhu
Copy link
Contributor Author

stanhu commented Jun 28, 2018

@ttaylorr Thanks!

@ttaylorr ttaylorr merged commit b6b2226 into git-lfs:master Jul 6, 2018
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.

None yet

2 participants