From 6b2e9e8af3ff3df2535ea8f38e176b4683bbbacb Mon Sep 17 00:00:00 2001 From: danielqsj Date: Tue, 26 Mar 2019 13:41:20 +0800 Subject: [PATCH] add completed job status in cronjob event --- pkg/controller/cronjob/controller.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/controller/cronjob/controller.go b/pkg/controller/cronjob/controller.go index 6e75744fc6..6fa66b3fac 100644 --- a/pkg/controller/cronjob/controller.go +++ b/pkg/controller/cronjob/controller.go @@ -219,7 +219,7 @@ func syncOne(sj *batchv1beta1.CronJob, js []batchv1.Job, now time.Time, jc jobCo childrenJobs[j.ObjectMeta.UID] = true found := inActiveList(*sj, j.ObjectMeta.UID) if !found && !IsJobFinished(&j) { - recorder.Eventf(sj, v1.EventTypeWarning, "UnexpectedJob", "Saw a job that the controller did not create or forgot: %v", j.Name) + recorder.Eventf(sj, v1.EventTypeWarning, "UnexpectedJob", "Saw a job that the controller did not create or forgot: %s", j.Name) // We found an unfinished job that has us as the parent, but it is not in our Active list. // This could happen if we crashed right after creating the Job and before updating the status, // or if our jobs list is newer than our sj status after a relist, or if someone intentionally created @@ -231,9 +231,9 @@ func syncOne(sj *batchv1beta1.CronJob, js []batchv1.Job, now time.Time, jc jobCo // in the same namespace "adopt" that job. ReplicaSets and their Pods work the same way. // TBS: how to update sj.Status.LastScheduleTime if the adopted job is newer than any we knew about? } else if found && IsJobFinished(&j) { + _, status := getFinishedStatus(&j) deleteFromActiveList(sj, j.ObjectMeta.UID) - // TODO: event to call out failure vs success. - recorder.Eventf(sj, v1.EventTypeNormal, "SawCompletedJob", "Saw completed job: %v", j.Name) + recorder.Eventf(sj, v1.EventTypeNormal, "SawCompletedJob", "Saw completed job: %s, status: %v", j.Name, status) } }