Alerting: bump rule version when updating rule group interval (#50295)
* Alerting: move group update to alert rule service * rename validateAlertRuleInterval to validateRuleGroupInterval * init baseinterval correctly * add seconds suffix * extract validation function for reusability * add context to err message
This commit is contained in:
@@ -376,3 +376,11 @@ func PatchPartialAlertRule(existingRule *AlertRule, ruleToPatch *AlertRule) {
|
||||
ruleToPatch.For = existingRule.For
|
||||
}
|
||||
}
|
||||
|
||||
func ValidateRuleGroupInterval(intervalSeconds, baseIntervalSeconds int64) error {
|
||||
if intervalSeconds%baseIntervalSeconds != 0 || intervalSeconds <= 0 {
|
||||
return fmt.Errorf("%w: interval (%v) should be non-zero and divided exactly by scheduler interval: %v",
|
||||
ErrAlertRuleFailedValidation, time.Duration(intervalSeconds)*time.Second, baseIntervalSeconds)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user