Skip to content

Commit

Permalink
fix: requeue ApplicationSet if there are validation errors (#14429) (#…
Browse files Browse the repository at this point in the history
…15206)

Signed-off-by: Chetan Banavikalmutt <[email protected]>
Co-authored-by: Chetan Banavikalmutt <[email protected]>
  • Loading branch information
gcp-cherry-pick-bot[bot] and chetan-rns authored Aug 24, 2023
1 parent bf77b09 commit f070882
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion applicationset/controllers/applicationset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ func (r *ApplicationSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}

requeueAfter := r.getMinRequeueAfter(&applicationSetInfo)
logCtx.WithField("requeueAfter", requeueAfter).Info("end reconcile")

if len(validateErrors) == 0 {
if err := r.setApplicationSetStatusCondition(ctx,
Expand All @@ -309,8 +308,13 @@ func (r *ApplicationSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque
); err != nil {
return ctrl.Result{}, err
}
} else if requeueAfter == time.Duration(0) {
// Ensure that the request is requeued if there are validation errors.
requeueAfter = ReconcileRequeueOnValidationError
}

logCtx.WithField("requeueAfter", requeueAfter).Info("end reconcile")

return ctrl.Result{
RequeueAfter: requeueAfter,
}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,7 @@ func TestReconcilerValidationErrorBehaviour(t *testing.T) {
// Verify that on validation error, no error is returned, but the object is requeued
res, err := r.Reconcile(context.Background(), req)
assert.Nil(t, err)
assert.True(t, res.RequeueAfter == 0)
assert.True(t, res.RequeueAfter == ReconcileRequeueOnValidationError)

var app v1alpha1.Application

Expand Down

0 comments on commit f070882

Please sign in to comment.