Skip to content

Commit

Permalink
Update JobSpec to support queue
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLike committed Mar 25, 2019
1 parent 7c369a8 commit 985070a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 16 deletions.
3 changes: 3 additions & 0 deletions pkg/apis/batch/v1alpha1/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ type JobSpec struct {
// Specifies the default lifecycle of tasks
// +optional
Policies []LifecyclePolicy `json:"policies,omitempty" protobuf:"bytes,6,opt,name=policies"`

//Specifies the queue that will be used in the scheduler, "default" queue is used this leaves empty.
Queue string `json:"queue,omitempty" protobuf:"bytes,7,opt,name=queue"`
}

// VolumeSpec defines the specification of Volume, e.g. PVC
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/batch/v1alpha1/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ const (
JobNamespaceKey = "volcano.sh/job-namespace"
DefaultTaskSpec = "default"
JobVersion = "volcano.sh/job-version"
QueueNameKey = "volcano.sh/queue-name"
)
6 changes: 1 addition & 5 deletions pkg/controllers/job/job_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,10 @@ func (cc *Controller) createPodGroupIfNotExist(job *vkv1.Job) error {
},
Spec: kbv1.PodGroupSpec{
MinMember: job.Spec.MinAvailable,
Queue: job.Spec.Queue,
},
}

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: 0 additions & 9 deletions pkg/controllers/job/job_controller_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,3 @@ 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 ""
}
2 changes: 1 addition & 1 deletion test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ 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,
Queue: jobSpec.queue,
},
}

Expand Down

0 comments on commit 985070a

Please sign in to comment.