-
Notifications
You must be signed in to change notification settings - Fork 71
add job priority for kube-batch scheduling #141 #45
Changes from 1 commit
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 |
---|---|---|
|
@@ -40,7 +40,7 @@ func (jc *JobController) deletePodsAndServices(runPolicy *apiv1.RunPolicy, job i | |
} | ||
return nil | ||
} | ||
|
||
// TTL means time to live | ||
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. This line, too. |
||
func (jc *JobController) cleanupJobIfTTL(runPolicy *apiv1.RunPolicy, jobStatus apiv1.JobStatus, job interface{}) error { | ||
currentTime := time.Now() | ||
metaObject, _ := job.(metav1.Object) | ||
|
@@ -191,6 +191,16 @@ func (jc *JobController) ReconcileJobs( | |
return jc.Controller.UpdateJobStatusInApiServer(job, &jobStatus) | ||
} | ||
|
||
if jc.Config.EnableGangScheduling { | ||
minAvailableReplicas := getTotalReplicas(replicas) | ||
priorityClassName := getPriorityClassName(runPolicy) | ||
//_, err := pc.SyncPodGroup(job, minAvailableReplicas) | ||
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. why keep this ? 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 reference the code about EnableGangScheduling of other operators and add the priority‘s’attribute and function. |
||
_, err := jc.SyncPodGroup(metaObject, minAvailableReplicas, priorityClassName) | ||
if err != nil { | ||
log.Warnf("Sync PodGroup %v: %v", jobName, err) | ||
} | ||
} | ||
|
||
// Save the current state of the replicas | ||
replicasStatus := make(map[string]v1.PodPhase) | ||
|
||
|
@@ -299,3 +309,14 @@ func (jc *JobController) cleanupJob(runPolicy *apiv1.RunPolicy, jobStatus apiv1. | |
jc.WorkQueue.AddRateLimited(key) | ||
return nil | ||
} | ||
func getPriorityClassName(runPolicy *apiv1.RunPolicy) string { | ||
priorityClassName := *runPolicy.SchedulingPolicy.PriorityClassName | ||
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. Runtime error here |
||
return priorityClassName | ||
} | ||
func getTotalReplicas(replicas map[apiv1.ReplicaType]*apiv1.ReplicaSpec) int32 { | ||
jobReplicas := int32(0) | ||
for _, r := range replicas { | ||
jobReplicas += *r.Replicas | ||
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 think we should check if r.Replicas is nil here, too. 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 got it |
||
} | ||
return jobReplicas | ||
} |
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.
We can remove this line