diff --git a/pkg/controller/scheduledjob/controller.go b/pkg/controller/scheduledjob/controller.go index 4c9c0322d88..ba837cb693c 100644 --- a/pkg/controller/scheduledjob/controller.go +++ b/pkg/controller/scheduledjob/controller.go @@ -149,10 +149,11 @@ func SyncOne(sj batch.ScheduledJob, js []batch.Job, now time.Time, jc jobControl } } } - err := sjc.UpdateStatus(&sj) + updatedSJ, err := sjc.UpdateStatus(&sj) if err != nil { - glog.Errorf("Unable to update status for %s: %v", nameForLog, err) + glog.Errorf("Unable to update status for %s (rv = %s): %v", nameForLog, sj.ResourceVersion, err) } + sj = *updatedSJ if sj.Spec.Suspend != nil && *sj.Spec.Suspend { glog.V(4).Infof("Not starting job for %s because it is suspended", nameForLog) @@ -280,8 +281,8 @@ func SyncOne(sj batch.ScheduledJob, js []batch.Job, now time.Time, jc jobControl sj.Status.Active = append(sj.Status.Active, *ref) } sj.Status.LastScheduleTime = &unversioned.Time{Time: scheduledTime} - if err := sjc.UpdateStatus(&sj); err != nil { - glog.Infof("Unable to update status for %s: %v", nameForLog, err) + if _, err := sjc.UpdateStatus(&sj); err != nil { + glog.Infof("Unable to update status for %s (rv = %s): %v", nameForLog, sj.ResourceVersion, err) } return diff --git a/pkg/controller/scheduledjob/injection.go b/pkg/controller/scheduledjob/injection.go index 11f9e5da075..26715df9783 100644 --- a/pkg/controller/scheduledjob/injection.go +++ b/pkg/controller/scheduledjob/injection.go @@ -29,7 +29,7 @@ import ( // sjControlInterface is an interface that knows how to update ScheduledJob status // created as an interface to allow testing. type sjControlInterface interface { - UpdateStatus(sj *batch.ScheduledJob) error + UpdateStatus(sj *batch.ScheduledJob) (*batch.ScheduledJob, error) } // realSJControl is the default implementation of sjControlInterface. @@ -39,9 +39,8 @@ type realSJControl struct { var _ sjControlInterface = &realSJControl{} -func (c *realSJControl) UpdateStatus(sj *batch.ScheduledJob) error { - _, err := c.KubeClient.Batch().ScheduledJobs(sj.Namespace).UpdateStatus(sj) - return err +func (c *realSJControl) UpdateStatus(sj *batch.ScheduledJob) (*batch.ScheduledJob, error) { + return c.KubeClient.Batch().ScheduledJobs(sj.Namespace).UpdateStatus(sj) } // fakeSJControl is the default implementation of sjControlInterface. @@ -51,9 +50,9 @@ type fakeSJControl struct { var _ sjControlInterface = &fakeSJControl{} -func (c *fakeSJControl) UpdateStatus(sj *batch.ScheduledJob) error { +func (c *fakeSJControl) UpdateStatus(sj *batch.ScheduledJob) (*batch.ScheduledJob, error) { c.Updates = append(c.Updates, *sj) - return nil + return sj, nil } // ------------------------------------------------------------------ //