Skip to content

Commit 91ae46e

Browse files
[release-1.16] Scheduler: log expected vreplicas by vpod (#8461)
Scheduler: log expected vreplicas by vpod Signed-off-by: Pierangelo Di Pilato <[email protected]> Co-authored-by: Pierangelo Di Pilato <[email protected]>
1 parent 741d6ec commit 91ae46e

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

pkg/scheduler/state/state.go

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,23 +278,25 @@ func isPodUnschedulable(pod *v1.Pod) bool {
278278
func (s *State) MarshalJSON() ([]byte, error) {
279279

280280
type S struct {
281-
FreeCap []int32 `json:"freeCap"`
282-
SchedulablePods []int32 `json:"schedulablePods"`
283-
Capacity int32 `json:"capacity"`
284-
Replicas int32 `json:"replicas"`
285-
StatefulSetName string `json:"statefulSetName"`
286-
PodSpread map[string]map[string]int32 `json:"podSpread"`
287-
Pending map[string]int32 `json:"pending"`
281+
FreeCap []int32 `json:"freeCap"`
282+
SchedulablePods []int32 `json:"schedulablePods"`
283+
Capacity int32 `json:"capacity"`
284+
Replicas int32 `json:"replicas"`
285+
StatefulSetName string `json:"statefulSetName"`
286+
PodSpread map[string]map[string]int32 `json:"podSpread"`
287+
Pending map[string]int32 `json:"pending"`
288+
ExpectedVReplicaByVPod map[string]int32 `json:"expectedVReplicaByVPod"`
288289
}
289290

290291
sj := S{
291-
FreeCap: s.FreeCap,
292-
SchedulablePods: s.SchedulablePods,
293-
Capacity: s.Capacity,
294-
Replicas: s.Replicas,
295-
StatefulSetName: s.StatefulSetName,
296-
PodSpread: ToJSONable(s.PodSpread),
297-
Pending: toJSONablePending(s.Pending),
292+
FreeCap: s.FreeCap,
293+
SchedulablePods: s.SchedulablePods,
294+
Capacity: s.Capacity,
295+
Replicas: s.Replicas,
296+
StatefulSetName: s.StatefulSetName,
297+
PodSpread: ToJSONable(s.PodSpread),
298+
Pending: toJSONablePending(s.Pending),
299+
ExpectedVReplicaByVPod: toJSONablePending(s.ExpectedVReplicaByVPod),
298300
}
299301

300302
return json.Marshal(sj)

pkg/scheduler/statefulset/autoscaler.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,19 @@ func (a *autoscaler) doautoscale(ctx context.Context, attemptScaleDown bool) err
205205
return err
206206
}
207207

208-
logger.Debugw("checking adapter capacity",
209-
zap.Int32("replicas", scale.Spec.Replicas),
210-
zap.Any("state", state))
211-
212208
newReplicas := integer.Int32Max(int32(math.Ceil(float64(state.TotalExpectedVReplicas())/float64(state.Capacity))), a.minReplicas)
213209

214210
// Only scale down if permitted
215211
if !attemptScaleDown && newReplicas < scale.Spec.Replicas {
216212
newReplicas = scale.Spec.Replicas
217213
}
218214

215+
logger.Debugw("checking adapter capacity",
216+
zap.Bool("attemptScaleDown", attemptScaleDown),
217+
zap.Int32("replicas", scale.Spec.Replicas),
218+
zap.Int32("newReplicas", newReplicas),
219+
zap.Any("state", state))
220+
219221
if newReplicas != scale.Spec.Replicas {
220222
scale.Spec.Replicas = newReplicas
221223
logger.Infow("updating adapter replicas", zap.Int32("replicas", scale.Spec.Replicas))

0 commit comments

Comments
 (0)