-
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
Task: Improvements to silences #3878
Comments
grobinson-grafana
changed the title
Task: Improvements to
Task: Improvements to silences
Jun 14, 2024
silences.go
grobinson-grafana
added a commit
to grobinson-grafana/alertmanager
that referenced
this issue
Jun 22, 2024
This commit fixes a number of bugs that can occur when creating and updating silences: 1. When creating a silence fails because the silence is invalid or would exceed limits, subsequent calls for the same silence fail even when the validation or limits are fixed. This happens because the silence is assigned an ID that does not exist. This commit fixes that issue as it assigns a new ID to silences that do not exist. 2. When updating an existing silence, and the update changes how alerts are matched or the time window in which the silence is active (excluding time extensions), then the existing silence must be expired and a new silence created. However, if the new silence is invalid or would exceed limits, the existing silence is expired, but the new silence is not created. This commit fixes that issue such that existing silences are not expired unless the replacing silence is both valid and within limits. Signed-off-by: George Robinson <[email protected]>
grobinson-grafana
added a commit
to grobinson-grafana/alertmanager
that referenced
this issue
Jun 22, 2024
This commit fixes a number of bugs that can occur when creating and updating silences: 1. When creating a silence fails because the silence is invalid or would exceed limits, subsequent calls for the same silence fail even when the validation or limits are fixed. This happens because the silence is assigned an ID that does not exist. This commit fixes that issue as it assigns a new ID to silences that do not exist. 2. When updating an existing silence, and the update changes how alerts are matched or the time window in which the silence is active (excluding time extensions), then the existing silence must be expired and a new silence created. However, if the new silence is invalid or would exceed limits, the existing silence is expired, but the new silence is not created. This commit fixes that issue such that existing silences are not expired unless the replacing silence is both valid and within limits. Signed-off-by: George Robinson <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are a number of issues with how silences work that I plan to fix:
silences.Set(*pb.Silence)
returns(id, error)
, where error is non-nil on failure. However, in some casessilences.Set
will set the ID for*pb.Silence
and return it even when the silence could not be stored (i.e. because it failed validation or would exceed limits). This ID does not exist, and does not refer to an actual stored silence. Subsequent calls tosilences.Set
will returnErrNotFound
.When an update to a silence requires expiring and re-creating the silence (i.e. when
canUpdate
returns false), if the new silence cannot be stored (i.e. because it failed validation or would exceed limits) the old silence is still expired. Updates should be atomic such that partial updates are not possible.The validation of silences happens in
silences.setSilence
, and this creates a lot of odd cases in the code. For example, we have a booleanskipValidate
that is used byexpire
to ensure existing silences can still be expired if the validation rules or limits change after the silence was created. It should be moved elsewhere.Like other fields, I think the maintenance function should be initialized in
silences.New
. It should be possible to replace the maintenance function at runtime withsilences.SetMaintenanceFunc
.The text was updated successfully, but these errors were encountered: