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

add context error check on merge of labels and label names #7277

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

erlan-z
Copy link

@erlan-z erlan-z commented Apr 12, 2024

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

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.

@erlan-z erlan-z force-pushed the context-cancellation-checks-for-get-label-merge branch 2 times, most recently from 7e2933e to cf606be Compare April 12, 2024 18:34
@erlan-z erlan-z marked this pull request as ready for review April 12, 2024 19:28
}

func mergeTwoStringSlices(a, b []string) []string {
func mergeTwoStringSlices(ctx context.Context, a, b []string) ([]string, error) {
Copy link
Contributor

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.

Copy link
Author

@erlan-z erlan-z Apr 16, 2024

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.

yeya24
yeya24 previously approved these changes Apr 19, 2024
Copy link
Contributor

@yeya24 yeya24 left a 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.

@erlan-z erlan-z force-pushed the context-cancellation-checks-for-get-label-merge branch from cf606be to 9b78e27 Compare April 30, 2024 22:41
Signed-off-by: Erlan Zholdubai uulu <erlanz@amazon.com>
@erlan-z erlan-z force-pushed the context-cancellation-checks-for-get-label-merge branch from 9b78e27 to ac4b0c6 Compare May 6, 2024 19:52
@erlan-z erlan-z requested a review from MichaHoffmann May 6, 2024 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants