Skip to content

Commit 1ba19c0

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 e8c5c54 commit 1ba19c0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

pkg/cache/cache.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ import (
4242
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
4343
)
4444

45-
var (
46-
defaultSyncPeriod = 10 * time.Hour
47-
)
45+
var defaultSyncPeriod = 10 * time.Hour
4846

4947
// InformerGetOptions defines the behavior of how informers are retrieved.
5048
type InformerGetOptions internal.GetOptions
@@ -172,6 +170,18 @@ type Options struct {
172170
// is "done" with an object, and would otherwise not requeue it, i.e., we
173171
// recommend the `Reconcile` function return `reconcile.Result{RequeueAfter: t}`,
174172
// instead of `reconcile.Result{}`.
173+
//
174+
// SyncPeriod will trigger update events with the old object being equal to the new
175+
// object. Excep the cache was out of sync.
176+
// If you filter update events like this:
177+
// Controller.Watch(
178+
// &source.Kind{Type: v1.MyCustomKind},
179+
// &handler.EnqueueRequestForObject{},
180+
// predicate.Or(predicate.GenerationChangedPredicate{},
181+
// predicate.LabelChangedPredicate{}))
182+
// then the SyncPeriod will not trigger a Reconcile call, because the update event
183+
// will be ignored by the predicate.
184+
175185
SyncPeriod *time.Duration
176186

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

0 commit comments

Comments
 (0)