provider/mesh: filter deleted silences from results
This commit is contained in:
parent
022adbff36
commit
c0103dd8c6
|
@ -174,7 +174,9 @@ func (s *Silences) All() ([]*types.Silence, error) {
|
|||
res := make([]*types.Silence, 0, len(s.st.m))
|
||||
|
||||
for _, sil := range s.st.m {
|
||||
res = append(res, sil)
|
||||
if !sil.Deleted() {
|
||||
res = append(res, sil)
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
@ -225,7 +227,7 @@ func (s *Silences) Get(id uuid.UUID) (*types.Silence, error) {
|
|||
defer s.st.mtx.RUnlock()
|
||||
|
||||
sil, ok := s.st.m[id]
|
||||
if !ok {
|
||||
if !ok || sil.Deleted() {
|
||||
return nil, provider.ErrNotFound
|
||||
}
|
||||
// TODO(fabxc): ensure that silence objects are never modified; just replaced.
|
||||
|
|
|
@ -298,6 +298,12 @@ func (s *Silence) Mutes(lset model.LabelSet) bool {
|
|||
return s.Matchers.Match(lset)
|
||||
}
|
||||
|
||||
// Returns whether a silence is deleted. Semantically this means it had no effect
|
||||
// on history at any point.
|
||||
func (s *Silence) Deleted() bool {
|
||||
return s.StartsAt.Equal(s.EndsAt)
|
||||
}
|
||||
|
||||
// NotifyInfo holds information about the last successful notification
|
||||
// of an alert to a receiver.
|
||||
type NotifyInfo struct {
|
||||
|
|
Loading…
Reference in New Issue