-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Do not create jobs until pg inqueue #634
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,7 +142,11 @@ func (cc *Controller) killJob(jobInfo *apis.JobInfo, podRetainPhase state.PhaseM | |
| return nil | ||
| } | ||
|
|
||
| func (cc *Controller) createJob(job *batch.Job) (*batch.Job, error) { | ||
| func (cc *Controller) initiateJob(job *batch.Job) (*batch.Job, error) { | ||
| klog.V(3).Infof("Starting to initiate Job <%s/%s>", job.Namespace, job.Name) | ||
| defer klog.V(3).Infof("Finished Job <%s/%s> initiate", job.Namespace, job.Name) | ||
|
|
||
| klog.Infof("Current Version is: %d of job: %s/%s", job.Status.Version, job.Namespace, job.Name) | ||
| job, err := cc.initJobStatus(job) | ||
| if err != nil { | ||
| cc.recorder.Event(job, v1.EventTypeWarning, string(batch.JobStatusError), | ||
|
|
@@ -185,9 +189,38 @@ func (cc *Controller) syncJob(jobInfo *apis.JobInfo, updateStatus state.UpdateSt | |
| return nil | ||
| } | ||
|
|
||
| var err error | ||
| if job, err = cc.createJob(job); err != nil { | ||
| return err | ||
| // Skip job initiation if job is already accepted | ||
| if job.Status.State.Phase == "" || job.Status.State.Phase == batch.Pending || job.Status.State.Phase == batch.Restarting { | ||
| var err error | ||
| if job, err = cc.initiateJob(job); err != nil { | ||
| return err | ||
| } | ||
| } | ||
| var syncTask bool | ||
| if pg, _ := cc.pgLister.PodGroups(job.Namespace).Get(job.Name); pg != nil { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we check this in handler?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure i am understanding what you mean. My thought is to split the SyncJob function: the first phase is initialization and the second phase is sync. |
||
| if pg.Status.Phase != "" && pg.Status.Phase != scheduling.PodGroupPending { | ||
| syncTask = true | ||
| } | ||
| } | ||
|
|
||
| if !syncTask { | ||
| if updateStatus != nil { | ||
| if updateStatus(&job.Status) { | ||
| job.Status.State.LastTransitionTime = metav1.Now() | ||
| } | ||
| } | ||
| newJob, err := cc.vcClient.BatchV1alpha1().Jobs(job.Namespace).UpdateStatus(job) | ||
| if err != nil { | ||
| klog.Errorf("Failed to update status of Job %v/%v: %v", | ||
| job.Namespace, job.Name, err) | ||
| return err | ||
| } | ||
| if e := cc.cache.Update(newJob); e != nil { | ||
| klog.Errorf("SyncJob - Failed to update Job %v/%v in cache: %v", | ||
| newJob.Namespace, newJob.Name, e) | ||
| return e | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| var running, pending, terminating, succeeded, failed, unknown int32 | ||
|
|
@@ -297,7 +330,6 @@ func (cc *Controller) syncJob(jobInfo *apis.JobInfo, updateStatus state.UpdateSt | |
| fmt.Sprintf("Error deleting pods: %+v", deletionErrs)) | ||
| return fmt.Errorf("failed to delete %d pods of %d", len(deletionErrs), len(podToDelete)) | ||
| } | ||
|
|
||
| job.Status = batch.JobStatus{ | ||
| State: job.Status.State, | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add
isInitializedfunc for this check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done