Skip to content

Commit aae628a

Browse files
authored
Fix: Adding 5 min to the reconciliation loop for apply_controller.go (#98)
* Adding 5 min to the reconciliation loop for apply_controller.go * edited unit test * edited unit test Co-authored-by: Youn Jae Kim <[email protected]>
1 parent 18190af commit aae628a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pkg/controllers/apply_controller.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"crypto/sha256"
2222
"encoding/json"
2323
"fmt"
24+
"time"
2425

2526
"github.com/pkg/errors"
2627
v1 "k8s.io/api/core/v1"
@@ -166,7 +167,7 @@ func (r *ApplyWorkReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
166167
utils.EventReasonReconcileComplete,
167168
utils.MessageManifestApplyComplete)
168169

169-
return ctrl.Result{}, nil
170+
return ctrl.Result{RequeueAfter: time.Minute * 5}, nil
170171
}
171172

172173
// applyManifests processes a given set of Manifests by: setting ownership, validating the manifest, and passing it on for application to the cluster.

pkg/controllers/apply_controller_unit_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ func TestReconcile(t *testing.T) {
466466
reconciler ApplyWorkReconciler
467467
req ctrl.Request
468468
wantErr error
469+
requeue bool
469470
}{
470471
"work cannot be retrieved, client failed due to client error": {
471472
reconciler: ApplyWorkReconciler{
@@ -618,6 +619,7 @@ func TestReconcile(t *testing.T) {
618619
},
619620
req: req,
620621
wantErr: nil,
622+
requeue: true,
621623
},
622624
}
623625
for testName, testCase := range testCases {
@@ -626,6 +628,9 @@ func TestReconcile(t *testing.T) {
626628
if testCase.wantErr != nil {
627629
assert.Containsf(t, err.Error(), testCase.wantErr.Error(), "incorrect error for Testcase %s", testName)
628630
} else {
631+
if testCase.requeue {
632+
assert.Equal(t, ctrl.Result{RequeueAfter: time.Minute * 5}, ctrlResult, "incorrect ctrlResult for Testcase %s", testName)
633+
}
629634
assert.Equalf(t, false, ctrlResult.Requeue, "incorrect ctrlResult for Testcase %s", testName)
630635
}
631636
})

0 commit comments

Comments
 (0)