Skip to content

Commit

Permalink
Restore back values
Browse files Browse the repository at this point in the history
Signed-off-by: kpharasi <[email protected]>
  • Loading branch information
kpharasi committed Dec 11, 2024
1 parent b597bcc commit e48653a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions admiral/pkg/controller/admiral/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 8 additions & 0 deletions admiral/pkg/controller/admiral/rollouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit e48653a

Please sign in to comment.