Skip to content

fix: spread vreplicas across minReplicas pods in scheduler - #9157

Merged
knative-prow[bot] merged 2 commits into
knative:mainfrom
creydr:fix/scheduler-minreplicas-spread
Jun 17, 2026
Merged

fix: spread vreplicas across minReplicas pods in scheduler#9157
knative-prow[bot] merged 2 commits into
knative:mainfrom
creydr:fix/scheduler-minreplicas-spread

Conversation

@creydr

@creydr creydr commented Jun 17, 2026

Copy link
Copy Markdown
Member

Summary

  • The autoscaler scales the dispatcher StatefulSet to at least minReplicas pods, but the scheduler only placed vreplicas equal to the requested count. This meant a VPod with fewer vreplicas than minReplicas would only use a subset of pods, leaving the remaining pods idle.
  • The scheduler now inflates the placement target to max(requested, min(minReplicas, schedulablePods)) so that vreplicas are spread across all available pods when minReplicas demands it.
  • Adds 6 test cases covering the new behavior (spread, cap at schedulable, normal when vreplicas > minReplicas, disabled, idempotent, scale-down).

The autoscaler scales the StatefulSet to at least minReplicas pods,
but the scheduler only placed vreplicas equal to the requested count.
This meant a ConsumerGroup with 1 vreplica would only use 1 pod,
leaving the other minReplicas-1 pods idle.

The scheduler now inflates the placement target to
max(requested, min(minReplicas, schedulablePods)) so that vreplicas
are spread across all available pods when minReplicas demands it.
@knative-prow knative-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 17, 2026
@knative-prow
knative-prow Bot requested review from Cali0707 and matzew June 17, 2026 09:23
@knative-prow knative-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 17, 2026
@creydr

creydr commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 68.75000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.04%. Comparing base (2996bf9) to head (b61a2e5).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/scheduler/statefulset/scheduler.go 68.75% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9157      +/-   ##
==========================================
- Coverage   51.06%   51.04%   -0.03%     
==========================================
  Files         411      411              
  Lines       22132    22142      +10     
==========================================
  Hits        11302    11302              
- Misses       9958     9965       +7     
- Partials      872      875       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The len(SchedulablePods) is bounded by cluster size and cannot
overflow int32.

@Cali0707 Cali0707 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 17, 2026
@knative-prow

knative-prow Bot commented Jun 17, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Cali0707, creydr

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

@knative-prow
knative-prow Bot merged commit 8cf4c4b into knative:main Jun 17, 2026
36 of 37 checks passed
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. lgtm Indicates that a PR is ready to be merged. 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.

2 participants