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

Cleanup object_store::retry client error handling #4915

Merged
merged 5 commits into from
Oct 11, 2023

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Oct 10, 2023

Which issue does this PR close?

Relates to #4880

Rationale for this change

The existing logic was hard to follow, with various different error variants overlayed onto the same structure. This makes these variants explicit, making the code easier to follow, and better able to support acting on error payloads.

What changes are included in this PR?

Are there any user-facing changes?

No, this error type is crate-private

}

/// Returns the error body if any
pub fn body(&self) -> Option<&str> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Being able to provide this method is what originally motivated this PR

@github-actions github-actions bot added the object-store Object Store Interface label Oct 10, 2023
@alamb alamb changed the title Cleanup client error handling Cleanup object_store client error handling Oct 10, 2023
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @tustvold

I found the naming to be a little confusing, as I commented.

I verified that this type does not appear to be public: https://docs.rs/object_store/0.7.1/object_store/?search=retry

Since it isn't a public API I think it could be merged as is (though I do think we should change the names / display of the errors)

#[snafu(display("Received redirect without LOCATION, this normally indicates an incorrectly configured region"))]
BareRedirect,

#[snafu(display("Client error with status {status}: {}", body.as_deref().unwrap_or("No Body")))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this techically a ServerError as is a value returned from the server (rather than some error trying to make the connecton?)

Copy link
Contributor Author

@tustvold tustvold Oct 10, 2023

Choose a reason for hiding this comment

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

It's a client error in the sense, the client did something wrong, which the server then complained about.

As per https://docs.rs/http/latest/http/status/struct.StatusCode.html#method.is_client_error

Or https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses

body: Option<String>,
},

#[snafu(display("Response error after {retries} retries: {source}"))]
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this kind of error normally called a ClientError or ConnectionError as it denotes a problem communicating with the server?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed "Response" to avoid confusion

object_store/src/client/retry.rs Show resolved Hide resolved
object_store/src/client/retry.rs Outdated Show resolved Hide resolved
@alamb alamb changed the title Cleanup object_store client error handling Cleanup object_store::retry client error handling Oct 10, 2023
@@ -39,8 +39,8 @@ pub enum Error {
body: Option<String>,
},

#[snafu(display("Response error after {retries} retries: {source}"))]
Response {
#[snafu(display("Error after {retries} retries: {source}"))]
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@tustvold tustvold merged commit d83008b into apache:master Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
object-store Object Store Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants