Skip to content

Commit b3ceb99

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 a173375 commit b3ceb99

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-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 interval. Defaults to defaultResyncTime.
8181
Resync *time.Duration
8282
}
8383

pkg/manager/manager.go

Lines changed: 5 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,9 @@ 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+
// Resync is the cache resync interval. Defaults to the cache default if unset.
80+
Resync *time.Duration
81+
7882
// Dependency injection for testing
7983
newCache func(config *rest.Config, opts cache.Options) (cache.Cache, error)
8084
newClient func(config *rest.Config, options client.Options) (client.Client, error)
@@ -120,7 +124,7 @@ func New(config *rest.Config, options Options) (Manager, error) {
120124
}
121125

122126
// Create the cache for the cached read client and registering informers
123-
cache, err := options.newCache(config, cache.Options{Scheme: options.Scheme, Mapper: mapper})
127+
cache, err := options.newCache(config, cache.Options{Scheme: options.Scheme, Mapper: mapper, Resync: options.Resync})
124128
if err != nil {
125129
return nil, err
126130

0 commit comments

Comments
 (0)