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