From 77e6d5a3ea75d5f8a44fd0db95371335d3e84f65 Mon Sep 17 00:00:00 2001 From: stonezdj Date: Tue, 2 Aug 2022 14:03:46 +0800 Subject: [PATCH] Return time.Time{} when cron string is empty change log level to debug to avoid noise Signed-off-by: stonezdj --- src/common/utils/utils.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/utils/utils.go b/src/common/utils/utils.go index 966d64dba8e..afb97a7abae 100644 --- a/src/common/utils/utils.go +++ b/src/common/utils/utils.go @@ -284,10 +284,13 @@ func FindNamedMatches(regex *regexp.Regexp, str string) map[string]string { // the cron string could contain 6 tokens // if the cron string is invalid, it returns a zero time func NextSchedule(cron string, curTime time.Time) time.Time { + if len(cron) == 0 { + return time.Time{} + } cr := strings.TrimSpace(cron) s, err := CronParser().Parse(cr) if err != nil { - log.Errorf("the cron string %v is invalid, error: %v", cron, err) + log.Debugf("the cron string %v is invalid, error: %v", cron, err) return time.Time{} } return s.Next(curTime)