-
Notifications
You must be signed in to change notification settings - Fork 77
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
Conversation
c3f0d23
to
e780e80
Compare
Signed-off-by: Ben Ye <benye@amazon.com>
Signed-off-by: Ben Ye <benye@amazon.com>
e780e80
to
383edf7
Compare
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.
Just a small comment apart from that lgtm
objstore.go
Outdated
b.metrics.opsFailures.WithLabelValues(op).Inc() | ||
} | ||
return err |
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.
We can omit this one no?
return err |
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.
Thanks. Good catch!
Addressed in the latest commit
Signed-off-by: Ben Ye <benye@amazon.com>
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.
lgtm
Signed-off-by: Ben Ye <benye@amazon.com>
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 anotherIsXXXError(err)
check to not log the error, which is very redundant to me.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