diff --git a/rollout/controller.go b/rollout/controller.go index 479c69bd4a..d9e09c9510 100644 --- a/rollout/controller.go +++ b/rollout/controller.go @@ -360,14 +360,6 @@ func (c *Controller) syncHandler(key string) error { return nil } - // In order to work with HPA, the rollout.Spec.Replica field cannot be nil. As a result, the controller will update - // the rollout to have the replicas field set to the default value. see https://github.com/argoproj/argo-rollouts/issues/119 - if rollout.Spec.Replicas == nil { - logCtx.Info("Defaulting .spec.replica to 1") - r.Spec.Replicas = pointer.Int32Ptr(defaults.DefaultReplicas) - _, err := c.argoprojclientset.ArgoprojV1alpha1().Rollouts(r.Namespace).Update(ctx, r, metav1.UpdateOptions{}) - return err - } defer func() { duration := time.Since(startTime) c.metricsServer.IncRolloutReconcile(r, duration) @@ -385,6 +377,15 @@ func (c *Controller) syncHandler(key string) error { return resolveErr } + // In order to work with HPA, the rollout.Spec.Replica field cannot be nil. As a result, the controller will update + // the rollout to have the replicas field set to the default value. see https://github.com/argoproj/argo-rollouts/issues/119 + if rollout.Spec.Replicas == nil { + logCtx.Info("Defaulting .spec.replica to 1") + r.Spec.Replicas = pointer.Int32Ptr(defaults.DefaultReplicas) + _, err := c.argoprojclientset.ArgoprojV1alpha1().Rollouts(r.Namespace).Update(ctx, r, metav1.UpdateOptions{}) + return err + } + err = roCtx.reconcile() if roCtx.newRollout != nil { c.writeBackToInformer(roCtx.newRollout)