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

Metric bucket should not return error when error is expected #103

Merged
merged 4 commits into from
Dec 12, 2024

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented Feb 27, 2024

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Now, when metric bucket got an error which is isOpFailureExpected, it doesn't increment the metric but still returns the error back to the caller.

For example, it is quite common to log the error returned by bucket operations like below. However, even if I already specify IsXXXError as expected, the error still returns and will be logged. To filter it out, I need to add another IsXXXError(err) check to not log the error, which is very redundant to me.

err := userBucket.ReaderWithExpectedErrs(IsXXXError).Iter(...)
level.Log("msg", "got error", "err", err)

We also have another usecase which doesn't support checking the error in the caller. https://github.com/cortexproject/cortex/blob/master/pkg/storage/bucket/s3/bucket_client.go#L135

We implemented our own storage provider which has retries. Since the error is returned, there is no way for the retryer to know if the error is expected or not and it will keep retrying and finally log the error. There is no way to inject the expected error to the bucket client itself in this case.

Verification

Signed-off-by: Ben Ye <benye@amazon.com>
Signed-off-by: Ben Ye <benye@amazon.com>
@yeya24 yeya24 force-pushed the do-not-return-error-when-expected branch from e780e80 to 383edf7 Compare December 11, 2024 00:46
Copy link
Collaborator

@JoaoBraveCoding JoaoBraveCoding left a comment

Choose a reason for hiding this comment

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

Just a small comment apart from that lgtm

objstore.go Outdated
b.metrics.opsFailures.WithLabelValues(op).Inc()
}
return err
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can omit this one no?

Suggested change
return err

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Good catch!
Addressed in the latest commit

Signed-off-by: Ben Ye <benye@amazon.com>
Copy link
Collaborator

@JoaoBraveCoding JoaoBraveCoding left a comment

Choose a reason for hiding this comment

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

lgtm

Signed-off-by: Ben Ye <benye@amazon.com>
@yeya24 yeya24 merged commit d69df72 into main Dec 12, 2024
7 checks passed
@yeya24 yeya24 deleted the do-not-return-error-when-expected branch December 12, 2024 21:39
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