Skip to content

Commit

Permalink
fix: default replica before resolving workloadRef
Browse files Browse the repository at this point in the history
- defaulting replica after workload ref is resolved

Signed-off-by: Hui Kang <[email protected]>
  • Loading branch information
Hui Kang committed Jun 24, 2021
1 parent 96ba030 commit 1c063ea
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions rollout/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 1c063ea

Please sign in to comment.