Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set replicas to MaxReplicas if HPA is enabled #833

Merged
merged 2 commits into from
Apr 27, 2022
Merged
Changes from 1 commit
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
16 changes: 11 additions & 5 deletions pkg/collector/reconcile/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,20 @@ func expectedDeployments(ctx context.Context, params Params, expected []appsv1.D
updated.ObjectMeta.Labels[k] = v
}

// if autoscale is enabled, use replicas from current Status
if params.Instance.Spec.MaxReplicas != nil {
currentReplicas := existing.Status.Replicas
// if replicas (minReplicas from HPA perspective) is bigger than
// current status use it.
if params.Instance.Spec.Replicas != nil && *params.Instance.Spec.Replicas > currentReplicas {
currentReplicas = *params.Instance.Spec.Replicas
if params.Instance.Spec.Replicas != nil {
// if replicas (minReplicas from HPA perspective) is bigger than
// current status use it.
if *params.Instance.Spec.Replicas > currentReplicas {
currentReplicas = *params.Instance.Spec.Replicas
}
// honor hpa max replicas parameter
if currentReplicas > *params.Instance.Spec.MaxReplicas {
currentReplicas = *params.Instance.Spec.MaxReplicas
}
}

updated.Spec.Replicas = &currentReplicas
}

Expand Down