Skip to content

[release-0.16] Finish old workload slice only after new slice is admitted#11558

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

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

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:23
@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.16 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 5d671c4
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-kueue/deploys/6a111dc75509cb0008e6af17
😎 Deploy Preview https://deploy-preview-11558--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 k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 23, 2026
@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 gabesaba, mbobrovskyi 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 the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label 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 adjusts workload-slice replacement ordering so the old slice is only finished after the replacement slice is admitted, and adds an integration assertion to prevent regressions.

Changes:

  • Move workload-slice replacement/finish logic to run after successful admission in the scheduler.
  • Add a watch-based test utility + integration test that asserts “new slice admitted before old slice finished”.
  • Update scheduler unit test expected event ordering accordingly.

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 watcher-based assertion helper for workload-slice ordering.
test/integration/singlecluster/controller/jobs/job/job_controller_test.go Adds an integration test to enforce the new ordering behavior.
pkg/scheduler/scheduler.go Reorders slice replacement to occur after admission; improves MultiKueue behavior by preserving ClusterName.
pkg/scheduler/scheduler_test.go Adjusts expected event order to match new 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 +1569 to +1576
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 on lines +679 to +683
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")
}
}
Comment thread test/util/util.go
ginkgo.GinkgoHelper()
oldSliceFinished := false
newSliceAdmitted := false
timeoutCh := time.After(timeout)
@sohankunkerkar
Copy link
Copy Markdown
Member Author

/test pull-kueue-verify-release-0-16

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@sohankunkerkar: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kueue-verify-release-0-16 5d671c4 link true /test pull-kueue-verify-release-0-16

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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