update read kv last notification time

This commit is contained in:
liugq 2022-04-27 11:03:17 +08:00
parent 24855bcd54
commit 56227db850
1 changed files with 6 additions and 3 deletions

View File

@ -583,9 +583,12 @@ func (engine *Engine) Do(rule *alerting.Rule) error {
if err != nil {
return fmt.Errorf("get last notification time from kv error: %w", err)
}
rule.LastNotificationTime, err = time.ParseInLocation(time.RFC3339, string(timeBytes), time.UTC)
if err != nil {
return fmt.Errorf("parse last notification time from kv error: %w", err)
timeStr := string(timeBytes)
if timeStr != ""{
rule.LastNotificationTime, err = time.ParseInLocation(time.RFC3339, string(timeBytes), time.UTC)
if err != nil {
return fmt.Errorf("parse last notification time from kv error: %w", err)
}
}
}
period := time.Now().Sub(rule.LastNotificationTime.Local())