Skip to content

Add --enable-gateway-api flag (auto/true/false) to fix startup crash without Gateway API CRDs#66

Merged
danieloliveira079 merged 1 commit intomainfrom
feature/enable-gateway-api-flag
Mar 27, 2026
Merged

Add --enable-gateway-api flag (auto/true/false) to fix startup crash without Gateway API CRDs#66
danieloliveira079 merged 1 commit intomainfrom
feature/enable-gateway-api-flag

Conversation

@danieloliveira079
Copy link
Copy Markdown
Contributor

Problem

Users not running the Gateway API backend hit a fatal startup crash because the controller unconditionally created a Gateway API informer. Without httproutes.gateway.networking.k8s.io CRD installed, the informer fails with:

failed to list *v1.HTTPRoute: the server could not find the requested resource

This broke all ingress-only users who upgraded to the version that added Gateway API support.

Solution

Add a --enable-gateway-api flag (default: auto) that probes for the HTTPRoute CRD at startup and conditionally enables the gateway backend:

Value Behaviour
auto (default) Detect at startup — enable if httproutes CRD is present, warn and disable if absent. Safe for all existing deployments.
true Always enable. Fail hard at startup if CRD is missing.
false Always disable. No informer or client created.

The detection checks for the httproutes resource specifically within gateway.networking.k8s.io/v1 — not just group presence — so other Gateway CRDs (gateways, gatewayclasses) being present without httproutes is correctly handled.

A nil-guard in GameSeverEventHandler.Reconcile returns a clear, actionable per-GameServer error if a fleet uses router-backend=gateway while the backend is disabled, rather than panicking.

Changes

  • pkg/app/controller.goresolveGatewayAPIEnabled + checkGatewayAPICRDs; Config.EnableGatewayAPI field
  • pkg/stores/store.goNewStore accepts gatewayEnabled bool; gateway client/informer created conditionally
  • pkg/handlers/gameserver_handler.goNewGameSeverEventHandler accepts gatewayEnabled bool; nil-guard with actionable error
  • cmd/root.go--enable-gateway-api flag wired in
  • deploy/install.yaml — image tag bumped to 0.5.0
  • MakefileRELEASE_TAG bumped to 0.5.0
  • README.md — Controller Flags section with --enable-gateway-api documented
  • AGENTS.md — Manual test procedure for all four scenarios

Test plan

  • --enable-gateway-api=auto with HTTPRoute CRD absent → warning logged, controller starts, ingress backend works
  • --enable-gateway-api=true with HTTPRoute CRD absent → fatal at startup with clear error
  • --enable-gateway-api=false → disabled log line, controller starts cleanly
  • --enable-gateway-api=auto with HTTPRoute CRD present → detected and enabled
  • go test ./... passes

All four scenarios were validated against the dev cluster before this PR.

🤖 Generated with Claude Code

Fixes a startup crash for users without Gateway API CRDs installed.
The controller previously always created a Gateway API informer, causing
a fatal error when httproutes.gateway.networking.k8s.io was not present.

The new --enable-gateway-api flag (default: auto) probes for the HTTPRoute
CRD at startup and conditionally enables the gateway backend:
- auto: enable if CRD present, warn and disable if absent (safe default)
- true: always enable, fail hard at startup if CRD is missing
- false: always disable, no informer or client created

A nil-guard in the handler returns a clear per-GameServer error if a fleet
requests router-backend=gateway while the backend is disabled.

Also bumps RELEASE_TAG and install.yaml image tag to 0.5.0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@danieloliveira079 danieloliveira079 merged commit b32839b into main Mar 27, 2026
1 check passed
@danieloliveira079 danieloliveira079 deleted the feature/enable-gateway-api-flag branch March 27, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant