Skip to content

Commit

Permalink
Fix log issue when failed to update job
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLike committed Jul 2, 2019
1 parent ae619b4 commit f08faa6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions pkg/controllers/job/job_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ func (cc *Controller) killJob(jobInfo *apis.JobInfo, podRetainPhase state.PhaseM
}

// Update Job status
job, err := cc.vkClients.BatchV1alpha1().Jobs(job.Namespace).UpdateStatus(job)
newJob, err := cc.vkClients.BatchV1alpha1().Jobs(job.Namespace).UpdateStatus(job)
if err != nil {
glog.Errorf("Failed to update status of Job %v/%v: %v",
job.Namespace, job.Name, err)
return err
}
if e := cc.cache.Update(job); e != nil {
if e := cc.cache.Update(newJob); e != nil {
glog.Errorf("KillJob - Failed to update Job %v/%v in cache: %v",
job.Namespace, job.Name, e)
newJob.Namespace, newJob.Name, e)
return e
}

Expand Down Expand Up @@ -185,15 +185,15 @@ func (cc *Controller) createJob(jobInfo *apis.JobInfo, updateStatus state.Update
}
}

job, err = cc.vkClients.BatchV1alpha1().Jobs(job.Namespace).UpdateStatus(job)
newJob, err := cc.vkClients.BatchV1alpha1().Jobs(job.Namespace).UpdateStatus(job)
if err != nil {
glog.Errorf("Failed to update status of Job %v/%v: %v",
job.Namespace, job.Name, err)
return err
}
if err = cc.cache.Update(job); err != nil {
if err = cc.cache.Update(newJob); err != nil {
glog.Errorf("CreateJob - Failed to update Job %v/%v in cache: %v",
job.Namespace, job.Name, err)
newJob.Namespace, newJob.Name, err)
return err
}

Expand Down Expand Up @@ -343,15 +343,15 @@ func (cc *Controller) syncJob(jobInfo *apis.JobInfo, updateStatus state.UpdateSt
job.Status.State.LastTransitionTime = metav1.Now()
}
}
job, err := cc.vkClients.BatchV1alpha1().Jobs(job.Namespace).UpdateStatus(job)
newJob, err := cc.vkClients.BatchV1alpha1().Jobs(job.Namespace).UpdateStatus(job)
if err != nil {
glog.Errorf("Failed to update status of Job %v/%v: %v",
job.Namespace, job.Name, err)
return err
}
if e := cc.cache.Update(job); e != nil {
if e := cc.cache.Update(newJob); e != nil {
glog.Errorf("SyncJob - Failed to update Job %v/%v in cache: %v",
job.Namespace, job.Name, e)
newJob.Namespace, newJob.Name, e)
return e
}

Expand Down Expand Up @@ -537,15 +537,15 @@ func (cc *Controller) initJobStatus(job *vkv1.Job) error {

job.Status.State.Phase = vkv1.Pending
job.Status.MinAvailable = int32(job.Spec.MinAvailable)
job, err := cc.vkClients.BatchV1alpha1().Jobs(job.Namespace).UpdateStatus(job)
newJob, err := cc.vkClients.BatchV1alpha1().Jobs(job.Namespace).UpdateStatus(job)
if err != nil {
glog.Errorf("Failed to update status of Job %v/%v: %v",
job.Namespace, job.Name, err)
return err
}
if err := cc.cache.Update(job); err != nil {
if err := cc.cache.Update(newJob); err != nil {
glog.Errorf("CreateJob - Failed to update Job %v/%v in cache: %v",
job.Namespace, job.Name, err)
newJob.Namespace, newJob.Name, err)
return err
}

Expand Down

0 comments on commit f08faa6

Please sign in to comment.