Skip to content

Commit beea757

Browse files
committed
Add a resync option to manager options
Allows setting the resync interval to something besides the default of 10 hours for all informers managed by the cache.
1 parent ec56f11 commit beea757

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

pkg/cache/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type Options struct {
7777
// Mapper is the RESTMapper to use for mapping GroupVersionKinds to Resources
7878
Mapper meta.RESTMapper
7979

80-
// Resync is the resync period
80+
// Resync is the resync period. Defaults to defaultResyncTime.
8181
Resync *time.Duration
8282
}
8383

pkg/manager/manager.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package manager
1818

1919
import (
2020
"fmt"
21+
"time"
2122

2223
"k8s.io/apimachinery/pkg/api/meta"
2324
"k8s.io/apimachinery/pkg/runtime"
@@ -75,6 +76,14 @@ type Options struct {
7576
// MapperProvider provides the rest mapper used to map go types to Kubernetes APIs
7677
MapperProvider func(c *rest.Config) (meta.RESTMapper, error)
7778

79+
// SyncPeriod determines the minimum frequency at which watched objects are
80+
// reconciled. A lower period will correct entropy more quickly but reduce
81+
// responsiveness to change. Choose a low value if reconciles are fast and/or
82+
// there are few objects to reconcile. Choose a high value if reconciles are
83+
// slow and/or there are many object to reconcile. Defaults to 10 hours if
84+
// unset.
85+
SyncPeriod *time.Duration
86+
7887
// Dependency injection for testing
7988
newCache func(config *rest.Config, opts cache.Options) (cache.Cache, error)
8089
newClient func(config *rest.Config, options client.Options) (client.Client, error)
@@ -120,7 +129,7 @@ func New(config *rest.Config, options Options) (Manager, error) {
120129
}
121130

122131
// Create the cache for the cached read client and registering informers
123-
cache, err := options.newCache(config, cache.Options{Scheme: options.Scheme, Mapper: mapper})
132+
cache, err := options.newCache(config, cache.Options{Scheme: options.Scheme, Mapper: mapper, Resync: options.SyncPeriod})
124133
if err != nil {
125134
return nil, err
126135

0 commit comments

Comments
 (0)