diff --git a/pkg/scheduler/state/state.go b/pkg/scheduler/state/state.go index 4f3ed659793..9075f43ab29 100644 --- a/pkg/scheduler/state/state.go +++ b/pkg/scheduler/state/state.go @@ -278,23 +278,25 @@ func isPodUnschedulable(pod *v1.Pod) bool { func (s *State) MarshalJSON() ([]byte, error) { type S struct { - FreeCap []int32 `json:"freeCap"` - SchedulablePods []int32 `json:"schedulablePods"` - Capacity int32 `json:"capacity"` - Replicas int32 `json:"replicas"` - StatefulSetName string `json:"statefulSetName"` - PodSpread map[string]map[string]int32 `json:"podSpread"` - Pending map[string]int32 `json:"pending"` + FreeCap []int32 `json:"freeCap"` + SchedulablePods []int32 `json:"schedulablePods"` + Capacity int32 `json:"capacity"` + Replicas int32 `json:"replicas"` + StatefulSetName string `json:"statefulSetName"` + PodSpread map[string]map[string]int32 `json:"podSpread"` + Pending map[string]int32 `json:"pending"` + ExpectedVReplicaByVPod map[string]int32 `json:"expectedVReplicaByVPod"` } sj := S{ - FreeCap: s.FreeCap, - SchedulablePods: s.SchedulablePods, - Capacity: s.Capacity, - Replicas: s.Replicas, - StatefulSetName: s.StatefulSetName, - PodSpread: ToJSONable(s.PodSpread), - Pending: toJSONablePending(s.Pending), + FreeCap: s.FreeCap, + SchedulablePods: s.SchedulablePods, + Capacity: s.Capacity, + Replicas: s.Replicas, + StatefulSetName: s.StatefulSetName, + PodSpread: ToJSONable(s.PodSpread), + Pending: toJSONablePending(s.Pending), + ExpectedVReplicaByVPod: toJSONablePending(s.ExpectedVReplicaByVPod), } return json.Marshal(sj) diff --git a/pkg/scheduler/statefulset/autoscaler.go b/pkg/scheduler/statefulset/autoscaler.go index 653ec12f156..3881e699eae 100644 --- a/pkg/scheduler/statefulset/autoscaler.go +++ b/pkg/scheduler/statefulset/autoscaler.go @@ -205,10 +205,6 @@ func (a *autoscaler) doautoscale(ctx context.Context, attemptScaleDown bool) err return err } - logger.Debugw("checking adapter capacity", - zap.Int32("replicas", scale.Spec.Replicas), - zap.Any("state", state)) - newReplicas := integer.Int32Max(int32(math.Ceil(float64(state.TotalExpectedVReplicas())/float64(state.Capacity))), a.minReplicas) // Only scale down if permitted @@ -216,6 +212,12 @@ func (a *autoscaler) doautoscale(ctx context.Context, attemptScaleDown bool) err newReplicas = scale.Spec.Replicas } + logger.Debugw("checking adapter capacity", + zap.Bool("attemptScaleDown", attemptScaleDown), + zap.Int32("replicas", scale.Spec.Replicas), + zap.Int32("newReplicas", newReplicas), + zap.Any("state", state)) + if newReplicas != scale.Spec.Replicas { scale.Spec.Replicas = newReplicas logger.Infow("updating adapter replicas", zap.Int32("replicas", scale.Spec.Replicas))