Skip to content

Prevent Cluster Autoscaler in MultiKueue manager cluster from scaling up nodes for Pod workloads - #12262

Merged
k8s-ci-robot merged 2 commits into
kubernetes-sigs:mainfrom
fg91:fg91/fix/multikueue-pod-cluster-autoscaler
Jun 15, 2026
Merged

k8s-ci-robot merged 2 commits into
kubernetes-sigs:mainfrom
fg91:fg91/fix/multikueue-pod-cluster-autoscaler

Conversation

@fg91

@fg91 fg91 commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug
/area multikueue

What this PR does / why we need it:

When a pod workload is admitted in a MultiKueue worker cluster, the cluster autoscaler in the management cluster triggers a scale up even though the pod will never run in the management cluster due to the scheduling gates. This PR prevents this.

Which issue(s) this PR fixes:

When a pod workload is created in the management cluster, the following is added to its spec and status:

  schedulingGates:
  - name: kueue.x-k8s.io/admission
  - name: kueue.x-k8s.io/topology
  conditions:
  - lastProbeTime: null
    lastTransitionTime: '...'
    message: Scheduling is blocked due to non-empty scheduling gates
    reason: SchedulingGated
    status: 'False'
    type: PodScheduled

Such a pod is not considered a scale up candidate by the cluster autoscaler.

However, once the pod is admitted in the worker cluster, the PodScheduled condition is currently overwritten with:

    conditions:
    - lastProbeTime: null
      lastTransitionTime: "..."
      message: '0/4 nodes are available: ...'
      observedGeneration: 2
      reason: Unschedulable
      status: "False"
      type: PodScheduled

The cluster autoscaler considers such a pod a scale up candidate despite the scheduling gates. Accordingly, I see a scale up event in the management cluster:

Pod triggered scale-up: [{https://... 0->1 (max: 1000)}]

This scale up in the management cluster doesn't make any sense as the workload will never run there. To prevent it, we must preserve the reason: SchedulingGated for the type: PodScheduled condition in the management cluster.

Does this PR introduce a user-facing change?

MultiKueue: Fixed a bug where admitted Pod workloads could trigger unnecessary Cluster Autoscaler scale-ups
in the manager cluster. Kueue now preserves the scheduling-gated PodScheduled condition for manager-cluster
Pods, since they are intended to run only in worker clusters.

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved Pod status synchronization to preserve the local PodScheduled condition when a Pod is scheduling-gated, while still keeping other status details in sync with the remote Pod.
  • Tests

    • Added coverage to ensure scheduling-gated manager Pod PodScheduled remains unchanged during job status synchronization.
  • E2E

    • Updated the multikueue end-to-end expectations to reflect the manager Pod staying scheduling-gated for its lifetime.

… up nodes for Pod workloads

Signed-off-by: Fabio Grätz <fabio@cusp.ai>
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. area/multikueue Issues or PRs related to MultiKueue needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 15, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @fg91. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot
k8s-ci-robot requested review from olekzabl and pajakd June 15, 2026 15:37
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

syncLocalPodWithRemote in the MultiKueue pod adapter is updated to preserve the local PodScheduled condition when the local pod is gated, instead of overwriting it with the remote pod's condition. Two helper functions (findPodCondition, setPodCondition) are added for condition management, two new unit test cases validate the behavior, and an e2e test expectation is aligned to reflect the preserved scheduling-gated state.

Changes

Gated PodScheduled condition preservation in MultiKueue sync

Layer / File(s) Summary
Sync logic and condition helpers
pkg/controller/jobs/pod/pod_multikueue_adapter.go
findPodCondition and setPodCondition helpers added for condition lookup and upsert. syncLocalPodWithRemote is updated to preserve the pre-overwrite local PodScheduled condition when the pod is gated, preventing the remote status overwrite from replacing the kueueschedulinggate-owned condition.
Unit tests for gated PodScheduled preservation
pkg/controller/jobs/pod/pod_multikueue_adapter_test.go
Two new TestMultiKueueAdapter cases assert that the manager pod's PodScheduled=False/PodReasonSchedulingGated condition is retained after SyncJob regardless of whether the remote worker pod reports unschedulable or fully scheduled status.
E2E test expectation for scheduling-gated pod
test/e2e/multikueue/baseline/e2e_test.go
E2E test expectation updated to reflect that the manager-cluster pod's PodScheduled condition remains False with reason SchedulingGated for its lifetime during the admitted pod scenario.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐇 Hoppy news from the scheduler lane,
A gated pod need not bear the unscheduled blame!
The local condition is safely tucked away,
While remote status arrives to display.
No autoscaler confusion, no misplaced shame —
The rabbit kept conditions exactly the same! 🌸

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: preserving SchedulingGated status to prevent cluster autoscaler scale-ups in MultiKueue manager clusters.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@mimowo

mimowo commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 15, 2026
@mimowo

mimowo commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

@fg91 that is a nice PR, thak you, please post a release note in the PR description in a dedicated block.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 15, 2026
@fg91

fg91 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

@fg91 that is a nice PR, thak you, please post a release note in the PR description in a dedicated block.

Done

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 15, 2026
@netlify

netlify Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit ca915b7
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-kueue/deploys/6a30238445ddd10008cbfe76

@fg91

fg91 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor Author

I'll adapt pull-kueue-test-e2e-multikueue-baseline-main.

Signed-off-by: Fabio Grätz <fabio@cusp.ai>
@mimowo

mimowo commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

/release-note-edit

MultiKueue: Fixed a bug where admitted Pod workloads could trigger unnecessary Cluster Autoscaler scale-ups
in the manager cluster. Kueue now preserves the scheduling-gated PodScheduled condition for manager-cluster
Pods, since they are intended to run only in worker clusters.

@mimowo

mimowo commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Looks great, thank you for hardening the MultiKueue implementation 👍
/lgtm
/approve
/cherrypick release-0.18
/cherrypick release-0.17

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown
Contributor

@mimowo: once the present PR merges, I will cherry-pick it on top of release-0.17, release-0.18 in new PRs and assign them to you.

Details

In response to this:

Looks great, thank you for hardening the MultiKueue implementation 👍
/lgtm
/approve
/cherrypick release-0.18
/cherrypick release-0.17

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.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 15, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: e0f9c1d48492f4a8eeab645e507e6ee47e317b10

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fg91, mimowo

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 15, 2026
@k8s-ci-robot
k8s-ci-robot merged commit 723b66d into kubernetes-sigs:main Jun 15, 2026
57 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.19 milestone Jun 15, 2026
@k8s-infra-cherrypick-robot

Copy link
Copy Markdown
Contributor

@mimowo: new pull request created: #12272

Details

In response to this:

Looks great, thank you for hardening the MultiKueue implementation 👍
/lgtm
/approve
/cherrypick release-0.18
/cherrypick release-0.17

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.

@k8s-infra-cherrypick-robot

Copy link
Copy Markdown
Contributor

@mimowo: new pull request created: #12273

Details

In response to this:

Looks great, thank you for hardening the MultiKueue implementation 👍
/lgtm
/approve
/cherrypick release-0.18
/cherrypick release-0.17

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.

kubernetes-prow Bot pushed a commit that referenced this pull request Jul 20, 2026
… cluster did schedule (#13136)

* Follow up #12262: MultiKueue sync pod scheduled condition when worker cluster did schedule

Signed-off-by: Fabio Grätz <fabio@cusp.ai>

* Fix existing and add new e2e test

Signed-off-by: Fabio Grätz <fabio@cusp.ai>

---------

Signed-off-by: Fabio Grätz <fabio@cusp.ai>
kubernetes-prow Bot pushed a commit that referenced this pull request Jul 20, 2026
…ion when worker cluster did schedule (#13198)

* Follow up #12262: MultiKueue sync pod scheduled condition when worker cluster did schedule

Signed-off-by: Fabio Grätz <fabio@cusp.ai>

* Fix existing and add new e2e test

Signed-off-by: Fabio Grätz <fabio@cusp.ai>

---------

Signed-off-by: Fabio Grätz <fabio@cusp.ai>
Co-authored-by: Fabio Grätz <fabio@cusp.ai>
kubernetes-prow Bot pushed a commit that referenced this pull request Jul 20, 2026
…ion when worker cluster did schedule (#13197)

* Follow up #12262: MultiKueue sync pod scheduled condition when worker cluster did schedule

Signed-off-by: Fabio Grätz <fabio@cusp.ai>

* Fix existing and add new e2e test

Signed-off-by: Fabio Grätz <fabio@cusp.ai>

---------

Signed-off-by: Fabio Grätz <fabio@cusp.ai>
Co-authored-by: Fabio Grätz <fabio@cusp.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/multikueue Issues or PRs related to MultiKueue cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants