-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fix inconsistent Id returned for silences.Set #3868
Fix inconsistent Id returned for silences.Set #3868
Conversation
This commit fixes inconsistent behavior of silences.Set where if a silence was invalid or exceeds limits, sil.Id would contain the silence UUID but the Id returned would be the empty string. This bug was introduced in prometheus#3866. Signed-off-by: George Robinson <[email protected]>
a97f41d
to
8da10ba
Compare
// If we got here it's either a new silence or a replacing one. | ||
if s.limits.MaxSilences > 0 { | ||
if len(s.st)+1 > s.limits.MaxSilences { | ||
return sil.Id, fmt.Errorf("exceeded maximum number of silences: %d (limit: %d)", len(s.st), s.limits.MaxSilences) |
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 return sil.Id
here as that's what happens if s.setSilence
returns an error too. s.setSilence
can return an error if the silence is invalid or maximum size has been exceeded.
I closed and then re-opened this PR as what I want to do is make sure |
} | ||
|
||
return sil.Id, nil | ||
return sil.Id, s.setSilence(sil, now, false) |
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.
This is how it was before #3852.
I'm going to close this in favor of doing the bigger changes, as mentioned here. |
This pull request fixes inconsistent behavior of
silences.Set()
where it can return an empty string and an error but also setsil.Id
to a UUID. This can happen when creating a silence that is invalid or exceeds limits. This bug was introduced in #3852.