Fix inconsistent Id returned for silences.Set#3868
Closed
grobinson-grafana wants to merge 1 commit intoprometheus:mainfrom
Closed
Fix inconsistent Id returned for silences.Set#3868grobinson-grafana wants to merge 1 commit intoprometheus:mainfrom
grobinson-grafana wants to merge 1 commit intoprometheus:mainfrom
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 <george.robinson@grafana.com>
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) |
Collaborator
Author
There was a problem hiding this comment.
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.
Collaborator
Author
|
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) |
Collaborator
Author
|
I'm going to close this in favor of doing the bigger changes, as mentioned here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request fixes inconsistent behavior of
silences.Set()where it can return an empty string and an error but also setsil.Idto a UUID. This can happen when creating a silence that is invalid or exceeds limits. This bug was introduced in #3852.