-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
add context error check on merge of labels and label names #7277
base: main
Are you sure you want to change the base?
add context error check on merge of labels and label names #7277
Conversation
7e2933e
to
cf606be
Compare
} | ||
|
||
func mergeTwoStringSlices(a, b []string) []string { | ||
func mergeTwoStringSlices(ctx context.Context, a, b []string) ([]string, error) { |
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.
I kinda dont understand why this function needs to check for context errors here. Its just processing two string slices.
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.
When slices are big enough, this merge was taking a lot of time and in cortex we saw it was processing even though request has timed out already, wasting the resources. I think this case is valid for Thanos as well.
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. I think this change makes sense to me. We have seen merging label names and values taking longer time than our configured timeout due to context not canceled.
9b78e27
to
ac4b0c6
Compare
Signed-off-by: Erlan Zholdubai uulu <erlanz@amazon.com>
ac4b0c6
to
ee863cd
Compare
Changes
Add context cancellation check on MergeSlices function in merge.go which is used on labels and label values merging.
Verification
Added unit test. However didn't add test case for context cancellation check because that would require wait time on tests which is not prefered.