Skip to content

Commit b9dd8fb

Browse files
authored
By default requeue the resource with 10 hour delay (#97)
Issue #, if available: aws-controllers-k8s/community#1355 Description of changes: * implement ReSync using `requeue.NeededAfter` instead of upstream controlle-runime's `SyncPeriod` * ACK controllers do not use cached go-client for reading objects from APIServer, hence upstream controller-runime ReSync was not working. Upstream controller-runtime ReSync only works for cached objects. * As part of this change, whenever the `RequeueOnSuccess` duration for an ACK resource is 0 , requeue it with a 10 hour delay to trigger ReSync. * I did not change the default value of `RequeueOnSuccessSeconds` from 0 to 10 hours because RequeueOnSuccessSeconds = 0 still means resource will not be requeued again to the developers. This 10 hour ReSync is an ACK runtime behavior and hence i only made change in ACK runtime. There will no change needed in existing ACK controllers. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 657c1c9 commit b9dd8fb

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pkg/runtime/reconciler.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ import (
4343

4444
const (
4545
backoffReadOneTimeout = 10 * time.Second
46+
// The default duration to trigger the sync for an ACK resource after
47+
// the successful reconciliation. This behavior for a resource can be
48+
// overriden by RequeueOnSuccessSeconds configuration for that resource.
49+
resyncPeriod = 10 * time.Hour
4650
)
4751

4852
// reconciler describes a generic reconciler within ACK.
@@ -836,6 +840,25 @@ func (r *resourceReconciler) handleRequeues(
836840
)
837841
return latest, requeue.NeededAfter(nil, time.Duration(duration)*time.Second)
838842
}
843+
// Since RequeueOnSuccessSeconds <= 0, requeue the resource
844+
// with "resyncPeriod" to perform periodic drift detection and
845+
// sync the desired state.
846+
//
847+
// Upstream controller-runtime provides SyncPeriod functionality
848+
// which flushes the go-client cache and triggers Sync for all
849+
// the objects in cache every 10 hours by default.
850+
//
851+
// ACK controller use non-cached client to read objects
852+
// from API Server, hence controller-runtime's SyncPeriod
853+
// functionality does not work.
854+
// https://github.com/aws-controllers-k8s/community/issues/1355
855+
//
856+
// ACK controllers use api-reader(non-cached client) to avoid
857+
// reading stale copies of ACK resource that can cause
858+
// duplicate resource creation when resource identifier is
859+
// not present in stale copy of resource.
860+
// https://github.com/aws-controllers-k8s/community/issues/894#issuecomment-911876354
861+
return latest, requeue.NeededAfter(nil, resyncPeriod)
839862
} else {
840863
rlog.Debug(
841864
"requeueing resource after finding resource synced condition false",

0 commit comments

Comments
 (0)