Skip to content
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

[release-0.3] Update the queue name in workload only when the job is standalone #718

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG/CHANGELOG-0.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## v0.4.0

Changes since `v0.3.0`:

### Bug fixes

- Fix a bug that updates a queue name in workloads with an empty value when using framework jobs that use batch/job internally, such as MPIJob. #713
2 changes: 1 addition & 1 deletion pkg/controller/jobframework/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (r *JobReconciler) ReconcileGenericJob(ctx context.Context, req ctrl.Reques

// update queue name if changed.
q := QueueName(job)
if wl.Spec.QueueName != q {
if wl.Spec.QueueName != q && isStandaloneJob {
log.V(2).Info("Job changed queues, updating workload")
wl.Spec.QueueName = q
err := r.client.Update(ctx, wl)
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/testingjobs/job/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (j *JobWrapper) Queue(queue string) *JobWrapper {
return j
}

// Queue updates the queue name of the job by annotation (deprecated)
// QueueNameAnnotation updates the queue name of the job by annotation (deprecated)
func (j *JobWrapper) QueueNameAnnotation(queue string) *JobWrapper {
j.Annotations[jobframework.QueueAnnotation] = queue
return j
Expand Down
27 changes: 27 additions & 0 deletions test/integration/controller/job/job_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,33 @@ var _ = ginkgo.Describe("Job controller", func() {
}, util.ConsistentDuration, util.Interval).Should(gomega.BeTrue())
})

ginkgo.It("Should not update the queue name of the workload with an empty value that the child job has", func() {
jobQueueName := "test-queue"

ginkgo.By("creating the parent job with queue name")
parentJob := testingjob.MakeJob(parentJobName, jobNamespace).Queue(jobQueueName).Obj()
gomega.Expect(k8sClient.Create(ctx, parentJob)).Should(gomega.Succeed())

ginkgo.By("waiting for the parent workload to be created")
parentWorkload := &kueue.Workload{}
gomega.Eventually(func() error {
return k8sClient.Get(ctx, parentWlLookupKey, parentWorkload)
}, util.Timeout, util.Interval).Should(gomega.Succeed())

ginkgo.By("Creating the child job which uses the parent workload annotation")
childJob := testingjob.MakeJob(childJobName, jobNamespace).ParentWorkload(parentWorkload.Name).Obj()
gomega.Expect(k8sClient.Create(ctx, childJob)).Should(gomega.Succeed())

ginkgo.By("Checking that the queue name of the parent workload isn't updated with an empty value")
parentWorkload = &kueue.Workload{}
gomega.Consistently(func() bool {
if err := k8sClient.Get(ctx, parentWlLookupKey, parentWorkload); err != nil {
return true
}
return parentWorkload.Spec.QueueName == jobQueueName
}, util.ConsistentDuration, util.Interval).Should(gomega.BeTrue())
})

ginkgo.It("Should change the suspension status of the child job when the parent workload is admitted or unadmitted", func() {
ginkgo.By("Create a resource flavor")
defaultFlavor := testing.MakeResourceFlavor("default").Label(labelKey, "default").Obj()
Expand Down