mirror of
https://github.com/prometheus/alertmanager
synced 2024-12-17 20:05:17 +00:00
Correctly call default silence maintenance function (#2701)
https://github.com/prometheus/alertmanager/pull/2689 introduced a regression where the default maintenance function would no longer be called even if no override was specified. The Alertmanager now crashes on any silence maintenance run without this fix. Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
44011410d7
commit
5195460c95
@ -378,7 +378,7 @@ func (s *Silences) Maintenance(interval time.Duration, snapf string, stopc <-cha
|
||||
return size, f.Close()
|
||||
}
|
||||
|
||||
if doMaintenance != nil {
|
||||
if override != nil {
|
||||
doMaintenance = override
|
||||
}
|
||||
|
||||
|
@ -180,6 +180,25 @@ func TestSilencesSnapshot(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// This tests a regression introduced by https://github.com/prometheus/alertmanager/pull/2689.
|
||||
func TestSilences_Maintenance_DefaultMaintenanceFuncDoesntCrash(t *testing.T) {
|
||||
f, err := ioutil.TempFile("", "snapshot")
|
||||
require.NoError(t, err, "creating temp file failed")
|
||||
s := &Silences{st: state{}, logger: log.NewNopLogger(), now: utcNow, metrics: newMetrics(nil, nil)}
|
||||
stopc := make(chan struct{})
|
||||
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
s.Maintenance(100*time.Millisecond, f.Name(), stopc, nil)
|
||||
close(done)
|
||||
}()
|
||||
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
close(stopc)
|
||||
|
||||
<-done
|
||||
}
|
||||
|
||||
func TestSilences_Maintenance_SupportsCustomCallback(t *testing.T) {
|
||||
f, err := ioutil.TempFile("", "snapshot")
|
||||
require.NoError(t, err, "creating temp file failed")
|
||||
|
Loading…
Reference in New Issue
Block a user