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

Default the isEqual flag to true in alertmanager #2603

Merged
merged 1 commit into from
May 27, 2021

Conversation

sinkingpoint
Copy link
Contributor

@sinkingpoint sinkingpoint commented May 27, 2021

Default the isEqual flag to true in alertmanager

Solves #2602 - the new version of alertmanager introduces an isEqual
flag to support != matchers in alertmanager silences. Clients set this
to true in the JSON blob sent to the api to indicate a foo=bar matcher,
and to false to indicate foo!=bar. Due to gos unmarshalling, anything
that doesn't include this flag will default to false (i.e. a !=
matcher), so any clients that aren't aware of this flag (such as amtools
before negative matchers and the new api) will not send it, and when you
think you are making a foo=bar matcher, alertmanager will interpret that
as a not equals.

This commit changes the Unmarshaling of the v1matcher struct to default
the IsEqual flag to true, to keep the old behaviour for clients not
setting the flag

Signed-off-by: sinkingpoint colin@quirl.co.nz

@sinkingpoint sinkingpoint changed the title Default the isEmpty flag to true in alertmanager Default the isEqual flag to true in alertmanager May 27, 2021
@sinkingpoint sinkingpoint force-pushed the master branch 2 times, most recently from b1f1ac8 to d6ae79f Compare May 27, 2021 09:13
pkg/labels/matcher.go Outdated Show resolved Hide resolved
@sinkingpoint sinkingpoint force-pushed the master branch 2 times, most recently from 238cb7f to 8f425b3 Compare May 27, 2021 09:29
Copy link
Member

@roidelapluie roidelapluie left a comment

Choose a reason for hiding this comment

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

Thank you. I have tested the fix and it works.

One last nit: can you rename the existing test TestMatcherJSONMarshal and add your tests to a TestMatcherJSONUnmarshal?

@roidelapluie
Copy link
Member

Also, if you could rebase on top of the branch release-0.22 this would be great - while not mandatory: if you do not rebase, I will simply cherry pick into the release branch.

@sinkingpoint sinkingpoint force-pushed the master branch 2 times, most recently from 2b87957 to 97006f3 Compare May 27, 2021 09:59
Solves prometheus#2602 - the new version of alertmanager introduces an isEqual
flag to support != matchers in alertmanager silences. Clients set this
to true in the JSON blob sent to the api to indicate a foo=bar matcher,
and to false to indicate foo!=bar. Due to gos unmarshalling, anything
that _doesn't_ include this flag will default to false (i.e. a !=
matcher), so any clients that aren't aware of this flag (such as amtools
before negative matchers and the new api) will not send it, and when you
think you are making a foo=bar matcher, alertmanager will interpret that
as a not equals.

This commit changes the Unmarshaling of the v1matcher struct to default
the IsEqual flag to true, to keep the old behaviour for clients not
setting the flag

Signed-off-by: sinkingpoint <colin@quirl.co.nz>
@sinkingpoint
Copy link
Contributor Author

sinkingpoint commented May 27, 2021

Done and done. Apologies for the initial scare - I'm glad the scope turned out to be less than I originally proposed

@roidelapluie roidelapluie changed the base branch from master to release-0.22 May 27, 2021 10:04
@roidelapluie
Copy link
Member

Done and done. Apologies for the initial scare - I'm glad the scope turned out to be less than I originally proposed

I expect that many people use the api v1 - without amtool. This is still an important bug.

@roidelapluie roidelapluie merged commit 53491b4 into prometheus:release-0.22 May 27, 2021
@roidelapluie
Copy link
Member

Thank you!

@beorn7
Copy link
Member

beorn7 commented May 27, 2021

Thanks for catching this. I thought we had covered it in the original change. But I vaguely remember that we thought about v1 API not as carefully, assuming it's rarely used and soon to be removed. But as @roidelapluie said, it should certainly keep working as expected as long as it is there.

@asquare14
Copy link
Contributor

Thank you for the catch and the speedy fix @sinkingpoint.

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.

4 participants