Skip to content

Commit

Permalink
ClusterCache: Increase timeout for informer List+Watch calls from 10s…
Browse files Browse the repository at this point in the history
… to 11m
  • Loading branch information
sbueringer committed Jan 27, 2025
1 parent 8b2a237 commit 74885dd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions controllers/clustercache/cluster_accessor_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,29 @@ func createUncachedClient(scheme *runtime.Scheme, config *rest.Config, httpClien

// createCachedClient creates a cached client for the given cluster, based on the rest.Config.
func createCachedClient(ctx context.Context, clusterAccessorConfig *clusterAccessorConfig, config *rest.Config, httpClient *http.Client, mapper meta.RESTMapper) (client.Client, *stoppableCache, error) {
// This config will only be used for List and Watch calls of informers
// because we don't want these requests to time out after the regular timeout
// of Options.Client.Timeout (default 10s).
// Lists of informers have no timeouts set.
// Watches of informers are timing out per default after [5m, 2*5m].
// https://github.com/kubernetes/client-go/blob/v0.32.0/tools/cache/reflector.go#L53-L55
// We are setting 11m to set a timeout for List calls without influencing Watch calls.
configWithHigherTimeout := rest.CopyConfig(config)
configWithHigherTimeout.Timeout = 11 * time.Minute
httpClientWithHigherTimeout, err := rest.HTTPClientFor(configWithHigherTimeout)
if err != nil {
return nil, nil, errors.Wrapf(err, "error creating cache: error creating HTTP client")
}

// Create the cache for the cluster.
cacheOptions := cache.Options{
HTTPClient: httpClient,
HTTPClient: httpClientWithHigherTimeout,
Scheme: clusterAccessorConfig.Scheme,
Mapper: mapper,
SyncPeriod: clusterAccessorConfig.Cache.SyncPeriod,
ByObject: clusterAccessorConfig.Cache.ByObject,
}
remoteCache, err := cache.New(config, cacheOptions)
remoteCache, err := cache.New(configWithHigherTimeout, cacheOptions)
if err != nil {
return nil, nil, errors.Wrapf(err, "error creating cache")
}
Expand Down

0 comments on commit 74885dd

Please sign in to comment.