From eb75a3303acf1ee2b04a4c1842855bafd9e54fc0 Mon Sep 17 00:00:00 2001 From: hangaoshuai Date: Wed, 4 Apr 2018 09:26:08 +0800 Subject: [PATCH] fixtodo:generate an event for a missed starting window --- pkg/controller/cronjob/cronjob_controller.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/controller/cronjob/cronjob_controller.go b/pkg/controller/cronjob/cronjob_controller.go index 5e10b4dca6a..80f8e04c328 100644 --- a/pkg/controller/cronjob/cronjob_controller.go +++ b/pkg/controller/cronjob/cronjob_controller.go @@ -273,9 +273,8 @@ func syncOne(sj *batchv1beta1.CronJob, js []batchv1.Job, now time.Time, jc jobCo } if tooLate { glog.V(4).Infof("Missed starting window for %s", nameForLog) - // TODO: generate an event for a miss. Use a warning level event because it indicates a - // problem with the controller (restart or long queue), and is not expected by user either. - // Since we don't set LastScheduleTime when not scheduling, we are going to keep noticing + recorder.Eventf(sj, v1.EventTypeWarning, "MissSchedule", "Missed scheduled time to start a job: %s", scheduledTime.Format(time.RFC1123Z)) + // TODO: Since we don't set LastScheduleTime when not scheduling, we are going to keep noticing // the miss every cycle. In order to avoid sending multiple events, and to avoid processing // the sj again and again, we could set a Status.LastMissedTime when we notice a miss. // Then, when we call getRecentUnmetScheduleTimes, we can take max(creationTimestamp,