Skip to content

Commit 4808f19

Browse files
committed
📖 Add more docs to SyncPeriod
SyncPeriod is likely to get ignored if you use a predicate. This PR updates the docs to make this more obvious.
1 parent 2704163 commit 4808f19

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/cache/cache.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,17 @@ type Options struct {
172172
// is "done" with an object, and would otherwise not requeue it, i.e., we
173173
// recommend the `Reconcile` function return `reconcile.Result{RequeueAfter: t}`,
174174
// instead of `reconcile.Result{}`.
175+
//
176+
// SyncPeriod will trigger update events with the old object being equal to the new
177+
// object, except when the cache was out of sync.
178+
// If you filter update events like this:
179+
// Controller.Watch(
180+
// &source.Kind{Type: v1.MyCustomKind},
181+
// &handler.EnqueueRequestForObject{},
182+
// predicate.Or(predicate.GenerationChangedPredicate{},
183+
// predicate.LabelChangedPredicate{}))
184+
// then the SyncPeriod will not trigger a Reconcile call, because the update event
185+
// will be ignored by the predicate.
175186
SyncPeriod *time.Duration
176187

177188
// ReaderFailOnMissingInformer configures the cache to return a ErrResourceNotCached error when a user

0 commit comments

Comments
 (0)