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

Task: Improvements to silences #3878

Open
grobinson-grafana opened this issue Jun 14, 2024 · 0 comments
Open

Task: Improvements to silences #3878

grobinson-grafana opened this issue Jun 14, 2024 · 0 comments

Comments

@grobinson-grafana
Copy link
Contributor

grobinson-grafana commented Jun 14, 2024

There are a number of issues with how silences work that I plan to fix:

  1. silences.Set(*pb.Silence) returns (id, error), where error is non-nil on failure. However, in some cases silences.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 to silences.Set will return ErrNotFound.

  2. 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.

  3. The validation of silences happens in silences.setSilence, and this creates a lot of odd cases in the code. For example, we have a boolean skipValidate that is used by expire 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.

  4. 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 with silences.SetMaintenanceFunc.

@grobinson-grafana grobinson-grafana changed the title Task: Improvements to silences.go Task: Improvements to silences Jun 14, 2024
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant