Skip to content

Commit 0fcf9d6

Browse files
authored
Merge pull request #2856 from k8s-infra-cherrypick-robot/cherry-pick-2846-to-release-0.7
[release-0.7] fix: added may resync check for EKS
2 parents aa68f94 + 1503b60 commit 0fcf9d6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

main.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ var (
9999
healthAddr string
100100
serviceEndpoints string
101101

102-
errEKSInvalidFlags = errors.New("invalid EKS flag combination")
102+
// maxEKSSyncPeriod is the maximum allowed duration for the sync-period flag when using EKS. It is set to 10 minutes
103+
// because during resync it will create a new AWS auth token which can a maximum life of 15 minutes and this ensures
104+
// the token (and kubeconfig secret) is refreshed before token expiration.
105+
maxEKSSyncPeriod = time.Minute * 10
106+
errMaxSyncPeriodExceeded = errors.New("sync period greater than maximum allowed")
107+
errEKSInvalidFlags = errors.New("invalid EKS flag combination")
103108
)
104109

105110
func main() {
@@ -282,6 +287,11 @@ func enableGates(ctx context.Context, mgr ctrl.Manager, awsServiceEndpoints []sc
282287
if feature.Gates.Enabled(feature.EKS) {
283288
setupLog.Info("enabling EKS controllers")
284289

290+
if syncPeriod > maxEKSSyncPeriod {
291+
setupLog.Error(errMaxSyncPeriodExceeded, "failed to enable EKS", "max-sync-period", maxEKSSyncPeriod, "syn-period", syncPeriod)
292+
os.Exit(1)
293+
}
294+
285295
enableIAM := feature.Gates.Enabled(feature.EKSEnableIAM)
286296
allowAddRoles := feature.Gates.Enabled(feature.EKSAllowAddRoles)
287297
setupLog.V(2).Info("EKS IAM role creation", "enabled", enableIAM)
@@ -432,7 +442,7 @@ func initFlags(fs *pflag.FlagSet) {
432442
fs.DurationVar(&syncPeriod,
433443
"sync-period",
434444
10*time.Minute,
435-
"The minimum interval at which watched resources are reconciled (e.g. 15m)",
445+
fmt.Sprintf("The minimum interval at which watched resources are reconciled. If EKS is enabled the maximum allowed is %s", maxEKSSyncPeriod),
436446
)
437447

438448
fs.IntVar(&webhookPort,

0 commit comments

Comments
 (0)