Skip to content

Commit

Permalink
controller: improve error for missed start times in cronjob
Browse files Browse the repository at this point in the history
The reclaimspacecronjob may miss too many runs due to the
following reasons:
- low startingDeadlineSeconds
- clock skew
- (added now) when user has reduced schedule which in turn
  leads to the new interval being < 100 times of old interval,
  aka >100 missed runs.

This issue only occurs when user changes schedule which
drastically reduces interval by more than 100 times.
Error message is improved to ask user to delete and
recreate cronjob to overcome this issue.

Signed-off-by: Rakshith R <[email protected]>
  • Loading branch information
Rakshith-R committed Jun 21, 2023
1 parent 870cc4e commit 5b27fe3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion controllers/csiaddons/reclaimspacecronjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,13 @@ func getNextSchedule(
starts++
if starts > 100 {
// We can't get the most recent times so just return an empty slice
// This may occur due to low startingDeadlineSeconds, clock skew or
// when user has reduced the schedule which in turn
// leads to the new interval being less than 100 times of the old interval.
return time.Time{}, time.Time{},
fmt.Errorf("too many missed start times (> 100). Set or decrease" +
".spec.startingDeadlineSeconds or check clock skew.")
".spec.startingDeadlineSeconds, check clock skew or" +
" delete and recreate reclaimspacecronjob.")
}
}
return lastMissed, sched.Next(now), nil
Expand Down

0 comments on commit 5b27fe3

Please sign in to comment.