Skip to content

Commit

Permalink
use status if autoscale is true
Browse files Browse the repository at this point in the history
Signed-off-by: Sergei Semenchuk <[email protected]>
  • Loading branch information
binjip978 committed Feb 27, 2022
1 parent 0c3f204 commit 5600157
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/collector/reconcile/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ func expectedDeployments(ctx context.Context, params Params, expected []appsv1.D
updated.Labels = map[string]string{}
}

// if autoscale is enabled, use replicas from current deployment
if params.Instance.Spec.Autoscale != nil && *params.Instance.Spec.Autoscale {
updated.Spec.Replicas = existing.Spec.Replicas
}

if desired.Labels["app.kubernetes.io/component"] == "opentelemetry-targetallocator" {
updated.Spec.Template.Spec.Containers[0].Image = desired.Spec.Template.Spec.Containers[0].Image
} else {
Expand All @@ -103,6 +98,11 @@ 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.Autoscale != nil && *params.Instance.Spec.Autoscale {
updated.Spec.Replicas = &existing.Status.Replicas
}

patch := client.MergeFrom(existing)

if err := params.Client.Patch(ctx, updated, patch); err != nil {
Expand Down

0 comments on commit 5600157

Please sign in to comment.