Repository navigation
Description
Description:
ProcessExtensionServerPolicies (internal/gatewayapi/extensionserverpolicy.go) does not support an ExtensionServerPolicy with targetRef.kind: GatewayClass. Such a policy is silently ignored — it produces no status, is not attached to any listener/gateway, and is dropped entirely from the output — regardless of whether mergeGateways is enabled or not.
This is not a mergeGateways-specific regression: GatewayClass was never a supported target kind for this policy type in the first place, in any mode.
Root cause, tracing what happens to targetRef.kind: GatewayClass:
isGateway/isListener(internal/gatewayapi/helpers.go) only matchKind == "Gateway", so the policy never reachesprocessExtensionServerPolicyForGateway— themergeGateways-awaregetIRKey/IRKeylogic (internal/gatewayapi/translator.go) is never invoked at all.isRoute/isRouteRuleonly checkKind != "Gateway"(too broad — they don't verify the kind is actually a route type), so aGatewayClasstarget is misrouted intoprocessExtensionServerPolicyForRoute.- There,
resolveExtServerPolicyRouteTargetReflooks the target up inrouteMap, which is keyed only by actual route kinds (HTTPRoute/GRPCRoute/etc). Nothing matches, so it returns(nil, nil)and the function returns early with no status set. - Back in
ProcessExtensionServerPolicies, the policy ends up with zero ancestor statuses, so it's filtered out of the returned slice — a completely silent no-op.
For comparison, EnvoyPatchPolicy handles this correctly (internal/gatewayapi/envoypatchpolicy.go): it explicitly branches on t.MergeGateways, requiring targetRef.kind == GatewayClass when merged (using the GatewayClass name directly as the IR key) and Gateway otherwise. ExtensionServerPolicy has no equivalent branch.
The extension-server docs (site/content/en/latest/tasks/extensibility/extension-server.md) only document Gateway and HTTPRoute/GRPCRoute as supported target kinds, and describe "target not found" as a silent skip with no condition written — which is technically what happens here, but a GatewayClass target is a reasonable, discoverable configuration that currently fails with zero feedback to the user.
Expected behavior:
Either:
ExtensionServerPolicyshould supporttargetRef.kind: GatewayClasswhenmergeGatewaysis enabled (mirroringEnvoyPatchPolicy's pattern), attaching the policy to all listeners under the merged Gateway set, or- If GatewayClass targeting is intentionally unsupported, the policy should receive an explicit
Accepted: False/ unsupported-kind status condition instead of being silently dropped (matching how an unsupported route kind like TCPRoute is already handled with an explicit rejection status).
Repro steps:
- Enable
mergeGatewaysfor a GatewayClass. - Create an
ExtensionServerPolicywithtargetRef: {group: gateway.networking.k8s.io, kind: GatewayClass, name: <gatewayclass-name>}. - Observe that the policy's extension hooks (e.g.
PostTranslateModifyHook) are never invoked for any Gateway/listener under that class, and the policy receives no status/condition of any kind.
Environment:
N/A — code-inspection finding in internal/gatewayapi/extensionserverpolicy.go (current main, commit 3ec9a0156).
Logs:
N/A — the failure is silent (no error, no status, no log output).
Activity
vishals-3 commentedon Sep 26, 2026
I traced this against current
mainand can confirm every step.Kind != Gatewayis the whole problem: aGatewayClasstarget satisfies it, gets dispatched intoprocessExtensionServerPolicyForRoute, missesrouteMap(keyed only by real route kinds), and returns early without setting status. The policy then never reaches the gateway pass either, sinceisGatewayrequiresKind == Gateway. So it is dropped with no condition, exactly as described.One thing worth flagging that widens the change beyond what the issue implies:
isRouteandisRouteRuleare shared by four policy types, not just this one —securitypolicy.go(L162, L186)envoyextensionpolicy.go(L149, L175)backendtrafficpolicy.go(L354, L380)extensionserverpolicy.go(L106, L127)So tightening them to match actual route kinds changes dispatch for SecurityPolicy, EnvoyExtensionPolicy and BackendTrafficPolicy too. That is arguably the correct fix — the same misrouting presumably affects an unsupported target kind on any of them — but it is a wider blast radius than a one-file change, and each of those has its own status-setting behaviour to keep consistent.
Which leaves a direction question I would rather have answered than guess at:
Accepted: False/Invalidcondition naming the kind. Matches the issue's point that GatewayClass was never supported, and fixes the silence without changing what is supported.GatewayClassa real target kind for ExtensionServerPolicy, attaching to every Gateway of that class.1 is the smaller change and addresses the actual complaint. 2 is a feature and would need its own design. Happy to implement either — and if 1, happy to scope it to ExtensionServerPolicy only, or fix the shared predicates across all four, whichever you prefer.
@arkodg @zirain
zirain commentedon Sep 28, 2026
@vishals-3 we need to support target to GatewayClass unless we deprecated merge gateways mode. I have sent out a fix in #10062.