Skip to content

Commit

Permalink
Merge pull request #944 from hzxuzhonghu/job-scheduler
Browse files Browse the repository at this point in the history
Fix: set pod's scheduler name to job's if not set
  • Loading branch information
volcano-sh-bot authored Jul 20, 2020
2 parents ffb5bb9 + 2749f1b commit 9c97afb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions pkg/controllers/job/job_controller_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func createJobPod(job *batch.Job, template *v1.PodTemplateSpec, ix int) *v1.Pod
Spec: templateCopy.Spec,
}

// If no scheduler name in Pod, use scheduler name from Job.
if len(pod.Spec.SchedulerName) == 0 {
pod.Spec.SchedulerName = job.Spec.SchedulerName
}

volumeMap := make(map[string]string)
for _, volume := range job.Spec.Volumes {
vcName := volume.VolumeClaimName
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/job/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,13 @@ func createJobWithPodGroup(ctx *testContext, jobSpec *jobSpec, pgName string) *b

func createJobInner(ctx *testContext, jobSpec *jobSpec) (*batchv1alpha1.Job, error) {
ns := getNS(ctx, jobSpec)

job := &batchv1alpha1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: jobSpec.name,
Namespace: ns,
},
Spec: batchv1alpha1.JobSpec{
SchedulerName: "volcano",
Policies: jobSpec.policies,
Queue: jobSpec.queue,
Plugins: jobSpec.plugins,
Expand Down Expand Up @@ -469,7 +469,6 @@ func createJobInner(ctx *testContext, jobSpec *jobSpec) (*batchv1alpha1.Job, err
Labels: task.labels,
},
Spec: v1.PodSpec{
SchedulerName: "volcano",
RestartPolicy: restartPolicy,
Containers: createContainers(task.img, task.command, task.workingDir, task.req, task.limit, task.hostport),
Affinity: task.affinity,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/scheduling/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ func createJobInner(ctx *testContext, jobSpec *jobSpec) (*batchv1alpha1.Job, err
Namespace: ns,
},
Spec: batchv1alpha1.JobSpec{
SchedulerName: "volcano",
Policies: jobSpec.policies,
Queue: jobSpec.queue,
Plugins: jobSpec.plugins,
Expand Down Expand Up @@ -469,7 +470,6 @@ func createJobInner(ctx *testContext, jobSpec *jobSpec) (*batchv1alpha1.Job, err
Labels: task.labels,
},
Spec: v1.PodSpec{
SchedulerName: "volcano",
RestartPolicy: restartPolicy,
Containers: createContainers(task.img, task.command, task.workingDir, task.req, task.limit, task.hostport),
Affinity: task.affinity,
Expand Down

0 comments on commit 9c97afb

Please sign in to comment.