Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions pkg/scheduler/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions pkg/scheduler/statefulset/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,19 @@ 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
if !attemptScaleDown && newReplicas < scale.Spec.Replicas {
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))
Expand Down
Loading