Skip to content

Add --cache-sync-timeout flag to make CacheSyncTimeout configurable - #4856

Open
itaibeny wants to merge 1 commit into
kubernetes-sigs:mainfrom
itaibeny:cache-sync-timeout-flag
Open

Add --cache-sync-timeout flag to make CacheSyncTimeout configurable#4856
itaibeny wants to merge 1 commit into
kubernetes-sigs:mainfrom
itaibeny:cache-sync-timeout-flag

Conversation

@itaibeny

@itaibeny itaibeny commented Jul 26, 2026

Copy link
Copy Markdown

Issue

Fixes #4855

Description

On large clusters (~12,000 Services, ~2,000 HTTPRoutes) with ALBGatewayAPI=true, the Gateway API controller's Service informer cache cannot sync within the hardcoded 2-minute CacheSyncTimeout from controller-runtime. This causes a crash-loop on startup:

failed to wait for gateway.k8s.aws/alb caches to sync kind source: *v1.Service:
timed out waiting for cache to be synced for Kind *v1.Service

The timeout is already configurable in controller-runtime via ctrl.Options.Controller.CacheSyncTimeout (see pkg/config/controller.go), but the LBC never exposes it. This PR wires it through:

  1. pkg/config/runtime_config.go — Add CacheSyncTimeout field to RuntimeConfig, register --cache-sync-timeout flag via BindFlags() (default: 2m, preserving current behavior), and pass it into opt.Controller.CacheSyncTimeout in BuildRuntimeOptions().
  2. pkg/config/runtime_config_test.go — Unit tests for the flag default, custom values, and the wiring into ctrl.Options.
  3. docs/deploy/configurations.md — Add cache-sync-timeout to the CLI flags table.
  4. helm/aws-load-balancer-controller/values.yaml — Add cacheSyncTimeout value (empty = use controller default).
  5. helm/aws-load-balancer-controller/templates/deployment.yaml — Conditional --cache-sync-timeout arg.

Why this is safe: default behavior is unchanged (2 minutes), no new dependencies, the field already exists in controller-runtime — we're just wiring it through.

Checklist

  • Added tests that cover your change (if possible)
  • Added/modified documentation as required (such as the README.md, or the docs directory)
  • Manually tested
  • Made sure the title of the PR is a good description that can go into the release notes

On large clusters with many Services or Gateway API resources, the
controller-runtime's hardcoded 2-minute CacheSyncTimeout causes the
controller to crash-loop on startup because informer caches cannot
sync in time.

Wire the existing controller-runtime config.Controller.CacheSyncTimeout
field through a new --cache-sync-timeout CLI flag (default: 2m, preserving
current behavior). Also add the corresponding Helm chart value
(cacheSyncTimeout) and documentation.

Signed-off-by: Itai Ben-Yishai <itaibeny@users.noreply.github.com>
@kubernetes-prow kubernetes-prow Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 26, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: itaibeny
Once this PR has been reviewed and has the lgtm label, please assign shraddhabang for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 26, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @itaibeny. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubernetes-prow kubernetes-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 26, 2026
@itaibeny
itaibeny marked this pull request as ready for review July 26, 2026 12:28
@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 26, 2026
@kubernetes-prow
kubernetes-prow Bot requested a review from zac-nixon July 26, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway API controller crash-loops on large clusters due to hardcoded CacheSyncTimeout

1 participant