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
Signed-off-by: Chetan Banavikalmutt <chetanrns1997@gmail.com>
  • Loading branch information
chetan-rns authored Aug 23, 2023
1 parent 2b15397 commit def685e
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 @@ -271,7 +271,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 @@ -285,8 +284,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 @@ -1859,7 +1859,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 argov1alpha1.Application

Expand Down

0 comments on commit def685e

Please sign in to comment.