Skip to content

Commit

Permalink
Add queue name support in job
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLike committed Mar 22, 2019
1 parent 2403639 commit d88aca1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/apis/batch/v1alpha1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ const (
JobNamespaceKey = "volcano.sh/job-namespace"
DefaultTaskSpec = "default"
JobVersion = "volcano.sh/job-version"
QueueNameKey = "volcano.sh/queue-name"
)
5 changes: 5 additions & 0 deletions pkg/controllers/job/job_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ func (cc *Controller) createPodGroupIfNotExist(job *vkv1.Job) error {
},
}

queue := GetJobQueueName(job)
if queue != "" {
pg.Spec.Queue = queue
}

if _, e := cc.kbClients.SchedulingV1alpha1().PodGroups(job.Namespace).Create(pg); e != nil {
glog.V(3).Infof("Failed to create PodGroup for Job <%s/%s>: %v",
job.Namespace, job.Name, err)
Expand Down
9 changes: 9 additions & 0 deletions pkg/controllers/job/job_controller_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,12 @@ func applyPolicies(job *vkv1.Job, req *apis.Request) vkv1.Action {

return vkv1.SyncJobAction
}

func GetJobQueueName(job *vkv1.Job) string {
for key, value := range job.Labels {
if key == vkv1.QueueNameKey {
return value
}
}
return ""
}
1 change: 1 addition & 0 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ func createJob(context *context, jobSpec *jobSpec) *vkv1.Job {
ObjectMeta: metav1.ObjectMeta{
Name: jobSpec.name,
Namespace: ns,
Labels: map[string]string{vkv1.QueueNameKey: jobSpec.queue},
},
Spec: vkv1.JobSpec{
Policies: jobSpec.policies,
Expand Down

0 comments on commit d88aca1

Please sign in to comment.