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

return an error when max retry is reached in executeMethod() #554

Closed
wants to merge 1 commit into from

Conversation

ericychoi
Copy link
Contributor

@ericychoi ericychoi commented Nov 21, 2016

DO NOT MERGE, missing tests.

@harshavardhana
Copy link
Member

This is not a bad idea but i think we can return the actual error rather than sending special error like retry. Right now it is sent it is just that DeleteObject() ignores it. You can modify that part of code instead.

@ericychoi
Copy link
Contributor Author

I believe err is not sent back to RemoveObject(). Since c.do() will not return an error on 500. (https://github.com/minio/minio-go/blob/master/api.go#L479)

It will return an error on closed connection or empty response, but not on a valid 500.

Now I can inspect resp in RemoveObject() and if it contains non-2xx status code, return an error to signify that to the client. Would you think that's better? Keep in mind then the same issue will keep happening for any other calls that use executeMethod() (update, for instance)

@harshavardhana
Copy link
Member

I believe err is not sent back to RemoveObject(). Since c.do() will not return an error on 500. (https://github.com/minio/minio-go/blob/master/api.go#L479)

It will return an error on closed connection or empty response, but not on a valid 500.

Now I can inspect resp in RemoveObject() and if it contains non-2xx status code, return an error to signify that to the client. Would you think that's better? Keep in mind then the same issue will keep happening for any other calls that use executeMethod() (update, for instance)

Yes in case of executeMethod() we should save the error regardless of the response codes.

@@ -528,6 +532,11 @@ func (c Client) executeMethod(method string, metadata requestMetadata) (res *htt
// For all other cases break out of the retry loop.
break
}

if retryCount >= MaxRetry {
err = errors.New("Max retry reached")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to declare the error once at the package level, and return that instead.

On the other hand, in this case, would you want to return the last error received? I was thinking if you just return "Max retry reached", the caller won't have any idea what the underlying error was.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is what we need here, we should only return the last error after all the retries.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said above, the last error is nil in this case, since c.Do() doesn't return error on 500.

I added an additional check here to make it clear (err == nil). I verified that this fixes my issue.

I can make another PR to attempt to fix this in RemoveObject(), but the point still stands this will keep happening for any other calls other than RemoveObject().

@ericychoi ericychoi force-pushed the handle-max-retry-error branch from daf976a to 61ddef2 Compare November 22, 2016 16:36
@ericychoi
Copy link
Contributor Author

Created #555 as an alternative approach.

@harshavardhana
Copy link
Member

You can close this @ericychoi

@harshavardhana
Copy link
Member

harshavardhana commented Nov 27, 2016

This approach is no longer needed. Thanks @ericychoi

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.

3 participants