Skip to content
This repository was archived by the owner on Apr 25, 2023. It is now read-only.

Commit 224fe95

Browse files
authored
Merge pull request #1460 from zqzten/cache_sync_timeout
feat: introduce informer cache sync timeout
2 parents 5b1f868 + bfd7751 commit 224fe95

File tree

20 files changed

+84
-30
lines changed

20 files changed

+84
-30
lines changed

charts/kubefed/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ chart and their default values.
115115
| controllermanager.featureGates.SchedulerPreferences | Scheduler preferences feature. | true |
116116
| controllermanager.clusterAvailableDelay | Time to wait before reconciling on a healthy cluster. | 20s |
117117
| controllermanager.clusterUnavailableDelay | Time to wait before giving up on an unhealthy cluster. | 60s |
118+
| controllermanager.cacheSyncTimeout | Time to wait for all caches to sync before exit. | 5m |
118119
| controllermanager.leaderElectLeaseDuration | The maximum duration that a leader can be stopped before it is replaced by another candidate. | 15s |
119120
| controllermanager.leaderElectRenewDeadline | The interval between attempts by the acting master to renew a leadership slot before it stops leading. This must be less than or equal to `controllermanager.LeaderElectLeaseDuration. | 10s |
120121
| controllermanager.leaderElectRetryPeriod | The duration the clients should wait between attempting acquisition and renewal of a leadership. | 5s |

charts/kubefed/charts/controllermanager/crds/crds.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,9 @@ spec:
645645
availableDelay:
646646
description: Time to wait before reconciling on a healthy cluster.
647647
type: string
648+
cacheSyncTimeout:
649+
description: Time to wait for all caches to sync before exit.
650+
type: string
648651
unavailableDelay:
649652
description: Time to wait before giving up on an unhealthy cluster.
650653
type: string

charts/kubefed/charts/controllermanager/templates/kubefedconfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ spec:
88
controllerDuration:
99
availableDelay: {{ .Values.clusterAvailableDelay | default "20s" | quote }}
1010
unavailableDelay: {{ .Values.clusterUnavailableDelay | default "60s" | quote }}
11+
cacheSyncTimeout: {{ .Values.cacheSyncTimeout | default "5m" | quote }}
1112
leaderElect:
1213
leaseDuration: {{ .Values.leaderElectLeaseDuration | default "15s" | quote }}
1314
renewDeadline: {{ .Values.leaderElectRenewDeadline | default "10s" | quote }}

charts/kubefed/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ controllermanager:
88
enabled: true
99
clusterAvailableDelay:
1010
clusterUnavailableDelay:
11+
cacheSyncTimeout:
1112
leaderElectLeaseDuration:
1213
leaderElectRenewDeadline:
1314
leaderElectRetryPeriod:

cmd/controller-manager/app/controller-manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ func setOptionsByKubeFedConfig(opts *options.Options) {
364364

365365
opts.Config.ClusterAvailableDelay = spec.ControllerDuration.AvailableDelay.Duration
366366
opts.Config.ClusterUnavailableDelay = spec.ControllerDuration.UnavailableDelay.Duration
367+
opts.Config.CacheSyncTimeout = spec.ControllerDuration.CacheSyncTimeout.Duration
367368

368369
opts.LeaderElection.ResourceLock = *spec.LeaderElect.ResourceLock
369370
opts.LeaderElection.RetryPeriod = spec.LeaderElect.RetryPeriod.Duration

config/kubefedconfig.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ spec:
88
controllerDuration:
99
availableDelay: 20s
1010
unavailableDelay: 60s
11+
cacheSyncTimeout: 5m
1112
leaderElect:
1213
leaseDuration: 1500ms
1314
renewDeadline: 1000ms

pkg/apis/core/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/core/v1beta1/defaults/defaults.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
const (
3030
DefaultClusterAvailableDelay = 20 * time.Second
3131
DefaultClusterUnavailableDelay = 60 * time.Second
32+
DefaultCacheSyncTimeout = 5 * time.Minute
3233

3334
DefaultLeaderElectionLeaseDuration = 15 * time.Second
3435
DefaultLeaderElectionRenewDeadline = 10 * time.Second
@@ -54,6 +55,7 @@ func SetDefaultKubeFedConfig(fedConfig *v1beta1.KubeFedConfig) {
5455
duration := spec.ControllerDuration
5556
setDuration(&duration.AvailableDelay, DefaultClusterAvailableDelay)
5657
setDuration(&duration.UnavailableDelay, DefaultClusterUnavailableDelay)
58+
setDuration(&duration.CacheSyncTimeout, DefaultCacheSyncTimeout)
5759

5860
if spec.LeaderElect == nil {
5961
spec.LeaderElect = &v1beta1.LeaderElectConfig{}

pkg/apis/core/v1beta1/defaults/defaults_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ func TestSetDefaultKubeFedConfig(t *testing.T) {
5050
SetDefaultKubeFedConfig(modifiedUnavailableDelayKFC)
5151
successCases["spec.controllerDuration.unavailableDelay is preserved"] = KubeFedConfigComparison{unavailableDelayKFC, modifiedUnavailableDelayKFC}
5252

53+
cacheSyncTimeoutKFC := defaultKubeFedConfig()
54+
cacheSyncTimeoutKFC.Spec.ControllerDuration.CacheSyncTimeout.Duration = DefaultCacheSyncTimeout + 31*time.Second
55+
modifiedCacheSyncTimeoutKFC := cacheSyncTimeoutKFC.DeepCopyObject().(*v1beta1.KubeFedConfig)
56+
SetDefaultKubeFedConfig(modifiedCacheSyncTimeoutKFC)
57+
successCases["spec.controllerDuration.cacheSyncTimeout is preserved"] = KubeFedConfigComparison{cacheSyncTimeoutKFC, modifiedCacheSyncTimeoutKFC}
58+
5359
// LeaderElect
5460
leaseDurationKFC := defaultKubeFedConfig()
5561
leaseDurationKFC.Spec.LeaderElect.LeaseDuration.Duration = DefaultLeaderElectionLeaseDuration + 11*time.Second

pkg/apis/core/v1beta1/kubefedconfig_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ type DurationConfig struct {
4848
// Time to wait before giving up on an unhealthy cluster.
4949
// +optional
5050
UnavailableDelay *metav1.Duration `json:"unavailableDelay,omitempty"`
51+
// Time to wait for all caches to sync before exit.
52+
// +optional
53+
CacheSyncTimeout *metav1.Duration `json:"cacheSyncTimeout,omitempty"`
5154
}
5255
type LeaderElectConfig struct {
5356
// The duration that non-leader candidates will wait after observing a leadership

0 commit comments

Comments
 (0)