Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix update issue #283

Merged
merged 1 commit into from
Jul 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions pkg/controllers/job/job_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,11 @@ func (cc *Controller) createJob(jobInfo *apis.JobInfo, updateStatus state.Update
job := jobInfo.Job.DeepCopy()
glog.Infof("Current Version is: %d of job: %s/%s", job.Status.Version, job.Namespace, job.Name)

if update, job, err := cc.initJobStatus(job); err != nil {
job, err := cc.initJobStatus(job)
if err != nil {
cc.recorder.Event(job, v1.EventTypeWarning, string(vkv1.JobStatusError),
fmt.Sprintf("Failed to initialize job status, err: %v", err))
return err
} else if update {
return nil
}

if err := cc.pluginOnJobAdd(job); err != nil {
Expand Down Expand Up @@ -539,9 +538,9 @@ func (cc *Controller) calcPGMinResources(job *vkv1.Job) *v1.ResourceList {
return &minAvailableTasksRes
}

func (cc *Controller) initJobStatus(job *vkv1.Job) (bool, *vkv1.Job, error) {
func (cc *Controller) initJobStatus(job *vkv1.Job) (*vkv1.Job, error) {
if job.Status.State.Phase != "" {
return false, job, nil
return job, nil
}

job.Status.State.Phase = vkv1.Pending
Expand All @@ -550,13 +549,13 @@ func (cc *Controller) initJobStatus(job *vkv1.Job) (bool, *vkv1.Job, error) {
if err != nil {
glog.Errorf("Failed to update status of Job %v/%v: %v",
job.Namespace, job.Name, err)
return false, nil, err
return nil, err
}
if err := cc.cache.Update(newJob); err != nil {
glog.Errorf("CreateJob - Failed to update Job %v/%v in cache: %v",
newJob.Namespace, newJob.Name, err)
return false, nil, err
return nil, err
}

return true, newJob, nil
return newJob, nil
}