Skip to content

Commit 335326b

Browse files
authored
fix: default replica before resolving workloadRef (argoproj#1304)
Signed-off-by: Hui Kang <[email protected]>
1 parent 460262e commit 335326b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

rollout/controller.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,6 @@ func (c *Controller) syncHandler(key string) error {
360360
return nil
361361
}
362362

363-
// In order to work with HPA, the rollout.Spec.Replica field cannot be nil. As a result, the controller will update
364-
// the rollout to have the replicas field set to the default value. see https://github.com/argoproj/argo-rollouts/issues/119
365-
if rollout.Spec.Replicas == nil {
366-
logCtx.Info("Defaulting .spec.replica to 1")
367-
r.Spec.Replicas = pointer.Int32Ptr(defaults.DefaultReplicas)
368-
_, err := c.argoprojclientset.ArgoprojV1alpha1().Rollouts(r.Namespace).Update(ctx, r, metav1.UpdateOptions{})
369-
return err
370-
}
371363
defer func() {
372364
duration := time.Since(startTime)
373365
c.metricsServer.IncRolloutReconcile(r, duration)
@@ -385,6 +377,15 @@ func (c *Controller) syncHandler(key string) error {
385377
return resolveErr
386378
}
387379

380+
// In order to work with HPA, the rollout.Spec.Replica field cannot be nil. As a result, the controller will update
381+
// the rollout to have the replicas field set to the default value. see https://github.com/argoproj/argo-rollouts/issues/119
382+
if rollout.Spec.Replicas == nil {
383+
logCtx.Info("Defaulting .spec.replica to 1")
384+
r.Spec.Replicas = pointer.Int32Ptr(defaults.DefaultReplicas)
385+
_, err := c.argoprojclientset.ArgoprojV1alpha1().Rollouts(r.Namespace).Update(ctx, r, metav1.UpdateOptions{})
386+
return err
387+
}
388+
388389
err = roCtx.reconcile()
389390
if roCtx.newRollout != nil {
390391
c.writeBackToInformer(roCtx.newRollout)

0 commit comments

Comments
 (0)