Skip to content

Extension server policies attach to every Gateway's listeners when mergeGateways is enabled #10097

Open

Description

@vvoytovych

Description:

With mergeGateways: true, an extension server policy (a kind listed in extensionManager.policyResources) that targets one Gateway is attached to the listeners of every Gateway in the GatewayClass.

Expected: the policy attaches only to the target Gateway's listeners, or only to the listener named by sectionName.

What happens instead:

  • Without sectionName, the policy is attached to every Gateway's listeners.
  • With sectionName, it is attached to every Gateway's listener of that name. The policy is also reported Accepted when only another Gateway has a listener with that name.
  • An HTTPListener post-hook can receive other Gateways' policies.
  • The number of attachments grows as policies × listeners. Up to v1.9.1, each attachment becomes a full copy of the policy in every stored copy of the IR. On main, after perf: store extension server resources centrally #10071, each attachment is a short reference, but the count is the same.

Cause: translateExtServerPolicyForGateway loops over every listener in the IR of the Gateway's IR key (code on main). With mergeGateways, that key is the GatewayClass, so the loop covers every Gateway. The sectionName check compares only the last segment of the IR listener name.

What we measured on a copy of a fleet with a few hundred merged Gateways (766 listeners) and about 100 Gateway-targeted policies, with an extension server that returns the resources unchanged, three runs each:

v1.7.4 v1.7.4 with the fix main 0dab73f main with the fix
listener attachments 79,664 267 79,664 267
of them on another Gateway's listener 79,397 0 79,397 0
controller live heap at rest 912 MiB 71 MiB 74 MiB 69 MiB

Attachments were counted on main; the v1.7.4 runs used the same objects. The live heap peak after a policy change was about 1.1 GiB on v1.7.4 and about 0.1 GiB on main.

On v1.7.4, 90% of the heap at rest is runtime.DeepCopyJSONValue, under watchable.(*Map).Store, ir.(*Xds).DeepCopyInto, ir.(*CoreListenerDetails).DeepCopyInto and ir.(*UnstructuredRef).DeepCopyInto.

On main, #10071 makes each attachment a reference with no object, so the memory is small. The wrong attachments remain.

Repro steps:

  1. A GatewayClass whose EnvoyProxy sets mergeGateways: true.
  2. Two Gateways in that class, gateway-a and gateway-b, each with listeners http and https.
  3. An extension manager with a policy kind in policyResources, and one policy that targets gateway-a.
  4. Translate. The IR listeners of gateway-b carry the policy in ExtensionRefs.

The linked PR adds this as a test. Without the fix, gateway-b/http and gateway-b/https carry both policies.

Environment:

Envoy Gateway v1.1.0 (#3371) through v1.9.1, and main at 0dab73f.

Logs:

No error is logged. The attachments show in the IR, and the cost shows in a heap profile.

Activity

  1. github-actions commented on Oct 24, 2026

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had activity in the last 30 days.

  2. zirain commented on Nov 4, 2026

    @zirain
    Member

    @vvoytovych can you check if this's fixed as part of #10062?

  3. vvoytovych commented on Nov 9, 2026

    @vvoytovych
    Author

    Yes, #10062 fixed this (7c22fe11): with mergeGateways, an extension server policy now attaches only to its target Gateway's listeners.

    #10379 adds the one case its test does not cover: two merged Gateways with same-named listeners, and a policy that targets one of them by sectionName. It closes this issue when it merges.

  4. zirain commented on Nov 9, 2026

    @zirain
    Member

    @vvoytovych FYI, I also created #10535 for v1.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions