Return time.Time{} when cron string is empty (#17289)

change log level to debug to avoid noise

Signed-off-by: stonezdj <stonezdj@gmail.com>
This commit is contained in:
stonezdj(Daojun Zhang) 2022-08-02 15:18:25 +08:00 committed by GitHub
parent b4f2f170b4
commit 66d34c8e0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)