From 3ea66ebe3fb7c2a0ece248f1c7fc524f225d8234 Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 17 Nov 2016 15:20:14 +0100 Subject: [PATCH] fix(alerting): remove possible divide by zero panic ref #6599 --- pkg/services/alerting/scheduler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/services/alerting/scheduler.go b/pkg/services/alerting/scheduler.go index b6ef1a63ff8..151f802ec15 100644 --- a/pkg/services/alerting/scheduler.go +++ b/pkg/services/alerting/scheduler.go @@ -39,6 +39,9 @@ func (s *SchedulerImpl) Update(rules []*Rule) { offset := ((rule.Frequency * 1000) / int64(len(rules))) * int64(i) job.Offset = int64(math.Floor(float64(offset) / 1000)) + if job.Offset == 0 { //zero offset causes division with 0 panics. + job.Offset = 1 + } jobs[rule.Id] = job }