Skip to content

Commit 8d2f1ca

Browse files
upgrade to latest dependencies (#4739)
bumping knative.dev/eventing 2996bf9...8cf4c4b: > 8cf4c4b fix: spread vreplicas across minReplicas pods in scheduler (# 9157) Signed-off-by: Knative Automation <automation@knative.team>
1 parent 9e6d780 commit 8d2f1ca

4 files changed

Lines changed: 31 additions & 10 deletions

File tree

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ require (
3535
k8s.io/client-go v0.35.6
3636
k8s.io/code-generator v0.35.6
3737
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4
38-
knative.dev/eventing v0.49.1-0.20260616033845-2996bf922daa
38+
knative.dev/eventing v0.49.1-0.20260617191249-8cf4c4b67303
3939
knative.dev/hack v0.0.0-20260428014158-b2a37f1b6e7b
4040
knative.dev/pkg v0.0.0-20260615201544-6300c57a9e78
4141
knative.dev/reconciler-test v0.0.0-20260616023650-a4d79b33cda4

‎go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,8 +1574,8 @@ k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
15741574
k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
15751575
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck=
15761576
k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
1577-
knative.dev/eventing v0.49.1-0.20260616033845-2996bf922daa h1:pZMOuMVy6GVo5nxuqIXFcl+wTe65yV+ipcHGfRuwCLI=
1578-
knative.dev/eventing v0.49.1-0.20260616033845-2996bf922daa/go.mod h1:qAdl4gctMP0BvhxtkM7QCalOHcwY62MjB4s9XYSwzAw=
1577+
knative.dev/eventing v0.49.1-0.20260617191249-8cf4c4b67303 h1:kG/rr63mOgmoEDzdYrDMIMIXfKPO0ycheUVQk94JtGA=
1578+
knative.dev/eventing v0.49.1-0.20260617191249-8cf4c4b67303/go.mod h1:qAdl4gctMP0BvhxtkM7QCalOHcwY62MjB4s9XYSwzAw=
15791579
knative.dev/hack v0.0.0-20260428014158-b2a37f1b6e7b h1:MvbV2F2BdI8qKrYYUhDwbUZbX0BAYRSIpXM2TOtTvs0=
15801580
knative.dev/hack v0.0.0-20260428014158-b2a37f1b6e7b/go.mod h1:L5RzHgbvam0u8QFHfzCX6MKxu/a/gIGEdaRBqNiVbl0=
15811581
knative.dev/pkg v0.0.0-20260615201544-6300c57a9e78 h1:l6cYazykii3EtY+DVcQOBMgGQ9WBnhAKeGRSo+15JiI=

‎vendor/knative.dev/eventing/pkg/scheduler/statefulset/scheduler.go‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ type StatefulSetScheduler struct {
115115
// replicas is the (cached) number of statefulset replicas.
116116
replicas int32
117117

118+
// minReplicas is the minimum number of replicas for the statefulset.
119+
// When set, the scheduler spreads vreplicas across at least this many pods.
120+
minReplicas int32
121+
118122
// isLeader signals whether a given Scheduler instance is leader or not.
119123
// The autoscaler is considered the leader when ephemeralLeaderElectionObject is in a
120124
// bucket where we've been promoted.
@@ -225,6 +229,7 @@ func newStatefulSetScheduler(ctx context.Context,
225229
stateAccessor: stateAccessor,
226230
reserved: make(map[types.NamespacedName]map[string]int32),
227231
autoscaler: autoscaler,
232+
minReplicas: cfg.MinReplicas,
228233
}
229234

230235
// Monitor our statefulset
@@ -377,34 +382,50 @@ func (s *StatefulSetScheduler) scheduleVPod(ctx context.Context, vpod scheduler.
377382
// - allocates as many vreplicas as possible to the same pod(s)
378383
// - allocates remaining vreplicas to new pods
379384

385+
// When minReplicas is set, ensure vreplicas are spread across at least
386+
// that many pods by inflating the target to max(requested, minReplicas).
387+
// Cap at schedulable pods to avoid requeueing when pods aren't ready yet.
388+
target := vpod.GetVReplicas()
389+
if s.minReplicas > target {
390+
schedulable := int32(len(state.SchedulablePods)) //nolint:gosec // G115: len is bounded by cluster size, cannot overflow int32
391+
if s.minReplicas < schedulable {
392+
target = s.minReplicas
393+
} else {
394+
target = schedulable
395+
}
396+
if target < vpod.GetVReplicas() {
397+
target = vpod.GetVReplicas()
398+
}
399+
}
400+
380401
// Exact number of vreplicas => do nothing
381402
tr := scheduler.GetTotalVReplicas(placements)
382-
if tr == vpod.GetVReplicas() {
403+
if tr == target {
383404
logger.Debug("scheduling succeeded (already scheduled)")
384405

385406
// Fully placed. Nothing to do
386407
return placements, nil
387408
}
388409

389410
// Need less => scale down
390-
if tr > vpod.GetVReplicas() {
391-
logger.Debugw("scaling down", zap.Int32("vreplicas", tr), zap.Int32("new vreplicas", vpod.GetVReplicas()),
411+
if tr > target {
412+
logger.Debugw("scaling down", zap.Int32("vreplicas", tr), zap.Int32("new vreplicas", target),
392413
zap.Any("placements", placements),
393414
zap.Any("existingPlacements", existingPlacements))
394415

395-
placements = s.removeReplicas(tr-vpod.GetVReplicas(), placements)
416+
placements = s.removeReplicas(tr-target, placements)
396417

397418
// Do not trigger the autoscaler to avoid unnecessary churn
398419

399420
return placements, nil
400421
}
401422

402423
// Need more => scale up
403-
logger.Debugw("scaling up", zap.Int32("vreplicas", tr), zap.Int32("new vreplicas", vpod.GetVReplicas()),
424+
logger.Debugw("scaling up", zap.Int32("vreplicas", tr), zap.Int32("new vreplicas", target),
404425
zap.Any("placements", placements),
405426
zap.Any("existingPlacements", existingPlacements))
406427

407-
placements, left := s.addReplicas(state, reservedByPodName, vpod, vpod.GetVReplicas()-tr, placements)
428+
placements, left := s.addReplicas(state, reservedByPodName, vpod, target-tr, placements)
408429

409430
if left > 0 {
410431
// Give time for the autoscaler to do its job

‎vendor/modules.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ k8s.io/utils/net
14171417
k8s.io/utils/pointer
14181418
k8s.io/utils/ptr
14191419
k8s.io/utils/trace
1420-
# knative.dev/eventing v0.49.1-0.20260616033845-2996bf922daa
1420+
# knative.dev/eventing v0.49.1-0.20260617191249-8cf4c4b67303
14211421
## explicit; go 1.25.0
14221422
knative.dev/eventing/cmd/event_display
14231423
knative.dev/eventing/cmd/heartbeats

0 commit comments

Comments
 (0)