diff --git a/admiral/pkg/controller/admiral/deployment.go b/admiral/pkg/controller/admiral/deployment.go index 82805a857..e3fc53703 100644 --- a/admiral/pkg/controller/admiral/deployment.go +++ b/admiral/pkg/controller/admiral/deployment.go @@ -88,15 +88,23 @@ func (d *DeploymentController) IsOnlyReplicaCountChanged(ctxLogger *log.Entry, o return false, fmt.Errorf("type assertion failed, %v is not of type *v1.Deployment", oldObj) } + // Temporarily storing replica count to use later after the check is complete + newReplicaCount := deploymentNew.Spec.Replicas + oldReplicaCount := deploymentOld.Spec.Replicas + deploymentNew.Spec.Replicas = nil deploymentOld.Spec.Replicas = nil if reflect.DeepEqual(deploymentOld.Spec, deploymentNew.Spec) { ctxLogger.Infof(ControllerLogFormat, "IsOnlyReplicaCountChanged", "", fmt.Sprintf("old and new spec matched for deployment excluding replica count %s", deploymentNew.Name)) + deploymentNew.Spec.Replicas = newReplicaCount + deploymentOld.Spec.Replicas = oldReplicaCount return true, nil } + deploymentNew.Spec.Replicas = newReplicaCount + deploymentOld.Spec.Replicas = oldReplicaCount return false, nil } diff --git a/admiral/pkg/controller/admiral/rollouts.go b/admiral/pkg/controller/admiral/rollouts.go index b7e93962a..db697aca9 100644 --- a/admiral/pkg/controller/admiral/rollouts.go +++ b/admiral/pkg/controller/admiral/rollouts.go @@ -93,15 +93,23 @@ func (rc *RolloutController) IsOnlyReplicaCountChanged(ctxLogger *log.Entry, obj return false, fmt.Errorf("type assertion failed, %v is not of type *argo.Rollout", oldObj) } + // Temporarily storing replica count to use later after the check is complete + newReplicaCount := rolloutNew.Spec.Replicas + oldReplicaCount := rolloutOld.Spec.Replicas + rolloutNew.Spec.Replicas = nil rolloutOld.Spec.Replicas = nil if reflect.DeepEqual(rolloutOld.Spec, rolloutNew.Spec) { ctxLogger.Infof(ControllerLogFormat, "IsOnlyReplicaCountChanged", "", fmt.Sprintf("old and new spec matched for rollout excluding replica count %s", rolloutNew.Name)) + rolloutNew.Spec.Replicas = newReplicaCount + rolloutOld.Spec.Replicas = oldReplicaCount return true, nil } + rolloutNew.Spec.Replicas = newReplicaCount + rolloutOld.Spec.Replicas = oldReplicaCount return false, nil }