Skip to content

[release-0.17] Finish old workload slice only after new slice is admitted#11557

Open
sohankunkerkar wants to merge 2 commits into
kubernetes-sigs:release-0.17from
sohankunkerkar:cherry-pick-11195-11292-0.17
Open

[release-0.17] Finish old workload slice only after new slice is admitted#11557
sohankunkerkar wants to merge 2 commits into
kubernetes-sigs:release-0.17from
sohankunkerkar:cherry-pick-11195-11292-0.17

Conversation

@sohankunkerkar
Copy link
Copy Markdown
Member

This is a manual cherry-pick of #11195 and #11292

/assign sohankunkerkar

ElasticJobViaWorkloadSlices: Fix quota leak during elastic workload scale-up where old slice was finished before replacement slice was admitted.

Copilot AI review requested due to automatic review settings May 23, 2026 03:08
@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label May 23, 2026
@k8s-ci-robot k8s-ci-robot added this to the v0.17 milestone May 23, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 23, 2026

Deploy Preview for kubernetes-sigs-kueue ready!

Name Link
🔨 Latest commit 2c159e5
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-kueue/deploys/6a111a1dc8811300087f2555
😎 Deploy Preview https://deploy-preview-11557--kubernetes-sigs-kueue.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sohankunkerkar
Once this PR has been reviewed and has the lgtm label, please assign mimowo for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 23, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR ensures correct ordering during elastic Job workload-slice replacement: the old workload-slice should not be marked Finished before the new slice becomes Admitted.

Changes:

  • Move workload-slice replacement/finishing to occur after the replacement slice is admitted (scheduler).
  • Add a watch-based test helper to assert ordering of “new admitted” vs “old finished”.
  • Add an integration test covering the ordering and adjust scheduler test event order.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
test/util/util.go Adds a watch-based assertion helper for workload-slice ordering.
test/integration/singlecluster/controller/jobs/job/job_controller_test.go Adds an integration test that sets up a Workload watch and verifies ordering on scale-up.
pkg/scheduler/scheduler.go Changes scheduler flow to admit the new slice first, then finish the old slice.
pkg/scheduler/scheduler_test.go Updates expected event ordering to match new scheduler behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/util/util.go
status, _ := evt.Object.(*metav1.Status)
gomega.Expect(evt.Type).ShouldNot(gomega.Equal(watch.Error), fmt.Sprintf("watch error: %v", status))
}
if evt.Type != watch.Modified {
Comment thread test/util/util.go
Comment on lines +1390 to +1397
if wl.Name == oldWorkloadName && workload.IsFinished(wl) {
oldSliceFinished = true
}
if wl.Name != oldWorkloadName && workload.IsAdmitted(wl) {
gomega.Expect(oldSliceFinished).Should(gomega.BeFalse(),
"old workload slice was finished before new slice was admitted")
newSliceAdmitted = true
}
Comment thread test/util/util.go
Comment on lines +1381 to +1382
status, _ := evt.Object.(*metav1.Status)
gomega.Expect(evt.Type).ShouldNot(gomega.Equal(watch.Error), fmt.Sprintf("watch error: %v", status))
Comment on lines +721 to +725
if features.Enabled(features.ElasticJobsViaWorkloadSlices) && oldWorkloadSlice != nil {
if err := s.replaceWorkloadSlice(ctx, oldWorkloadSlice.WorkloadInfo.ClusterQueue, e.Obj, oldWorkloadSlice.WorkloadInfo.Obj.DeepCopy()); err != nil {
log.Error(err, "Failed to finish old workload slice after admitting replacement; job reconciler will handle recovery")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants