From 4bda41905cd78a0934dbf950132ae03ef23f23f8 Mon Sep 17 00:00:00 2001 From: Janet Kuo Date: Wed, 24 Aug 2016 14:54:48 -0700 Subject: [PATCH 1/2] Update sj on UpdateStatus return value --- pkg/controller/scheduledjob/injection.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controller/scheduledjob/injection.go b/pkg/controller/scheduledjob/injection.go index 11f9e5da075..6c7b14d9708 100644 --- a/pkg/controller/scheduledjob/injection.go +++ b/pkg/controller/scheduledjob/injection.go @@ -40,7 +40,7 @@ type realSJControl struct { var _ sjControlInterface = &realSJControl{} func (c *realSJControl) UpdateStatus(sj *batch.ScheduledJob) error { - _, err := c.KubeClient.Batch().ScheduledJobs(sj.Namespace).UpdateStatus(sj) + sj, err := c.KubeClient.Batch().ScheduledJobs(sj.Namespace).UpdateStatus(sj) return err } From 2b87b46a6f2edeb204728517d31b5329fa34fb5e Mon Sep 17 00:00:00 2001 From: Janet Kuo Date: Wed, 24 Aug 2016 17:44:25 -0700 Subject: [PATCH 2/2] fixup --- pkg/controller/scheduledjob/controller.go | 9 +++++---- pkg/controller/scheduledjob/injection.go | 11 +++++------ 2 files changed, 10 insertions(+), 10 deletions(-) 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 6c7b14d9708..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 { - sj, 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 } // ------------------------------------------------------------------ //