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

feat: add version check for thanos. keep_firing_for now available #6283

Conversation

DeamonMV
Copy link
Contributor

@DeamonMV DeamonMV commented Feb 2, 2024

Description

Added version check for thanos in the context of keep_firing_for. starting from thanos v0.34.0 keep_firing_for is available.

Type of change

What type of changes does your code introduce to the Prometheus operator? Put an x in the box that apply.

  • CHANGE (fix or feature that would cause existing functionality to not work as expected)
  • FEATURE (non-breaking change which adds functionality)
  • BUGFIX (non-breaking change which fixes an issue)
  • ENHANCEMENT (non-breaking change which improves existing functionality)
  • NONE (if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)

Verification

Please check the Prometheus-Operator testing guidelines for recommendations about automated tests.

Changelog entry

feat: add version check for thanos. keep_firing_for now available

…r. starting from thanos v0.34.0 keep_firing_for is available.
@slashpai
Copy link
Contributor

slashpai commented Feb 2, 2024

You need to add test for supported and unsupported version in

t.Run("shouldDropKeepFiringForThanos", shouldDropKeepFiringForThanos)

@simonpasquier
Copy link
Contributor

There's also no need to keep the existing switch/case.

…keep_firing_for, to check thanos version, which support and not support keep_firing_for.
@pull-request-size pull-request-size bot added size/M and removed size/XS labels Feb 2, 2024
@DeamonMV
Copy link
Contributor Author

DeamonMV commented Feb 2, 2024

@slashpai @simonpasquier

I have pushed changes, could you guys, please, check if it's legitimately\correct?

content, _ := pr.generateRulesConfiguration(rules)
if strings.Contains(content, "keep_firing_for") {
t.Fatalf("expected `keep_firing_for` not to be present in PrometheusRule")
testCases := []struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

The test doesn't work as expected: the second sub-test should return a snippet with keep_firing_for. It's because generateRulesConfiguration() mutates the rules struct.
Also the shouldDropKeepFiringForThanos test function needs to be renamed or a new test function should be added.

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 hope I got your point.
Changes were pushed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@simonpasquier can you please check if my changes are good?

…check keep_firing_for is dropped, second - accepted
@@ -227,7 +228,7 @@ func shouldAcceptRuleWithKeepFiringForPrometheus(t *testing.T) {
}
}

func shouldDropKeepFiringForThanos(t *testing.T) {
func shouldDropRuleFiringForThanos(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big deal but you could have kept the original name?

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 made this by example of Prometheus - Accept and Drop.
And, I guess, because of now it's possible to use and that option can be Accepted and should be Dropped in case of version of thanos is "old".

Copy link
Contributor

@simonpasquier simonpasquier left a comment

Choose a reason for hiding this comment

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

Thanks!

@simonpasquier simonpasquier merged commit c5098f5 into prometheus-operator:main Feb 8, 2024
17 checks passed
@DeamonMV DeamonMV deleted the ferature-thanos-keep-firing-for branch February 8, 2024 14:50
@DeamonMV
Copy link
Contributor Author

DeamonMV commented Feb 8, 2024

I guess it would be good to squash commits, but I was to late :)

@simonpasquier
Copy link
Contributor

No issue, I've squashed on merge :)

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