Explorar el Código

fix(alerting): remove possible divide by zero panic

ref #6599
bergquist hace 9 años
padre
commit
3ea66ebe3f
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  1. 3 0
      pkg/services/alerting/scheduler.go

+ 3 - 0
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
 	}