Skip to content

BackendTrafficPolicy RoutingType ignores MergeType, always inherits from broader-scoped policies #9541

Closed

Description

@muwaqar-cflt

BackendTrafficPolicySpec.MergeType's doc comment states: "If unset, no merging occurs, and only the most specific configuration takes effect." This is correctly enforced for most fields via mergeBackendTrafficPolicy (internal/gatewayapi/backendtrafficpolicy.go), which ignores the parent (broader-scoped) policy entirely when MergeType is unset.

However, RoutingType is resolved through a completely separate path: BTPRoutingTypeIndex / LookupBTPRoutingType (internal/gatewayapi/backendtrafficpolicy.go). This does an unconditional route-rule -> route -> listener -> gateway fallthrough, returning the first non-nil RoutingType it finds, with no reference to MergeType anywhere in the lookup or in BuildBTPIndexes' population of the index.

Result: a route-rule-level BackendTrafficPolicy with MergeType unset (which per the field's own doc comment should mean "only this configuration takes effect") will still silently inherit RoutingType from a listener- or gateway-level BackendTrafficPolicy, even though no other field on that policy is allowed to inherit from the parent.

Expected: RoutingType resolution should respect MergeType the same way other BackendTrafficPolicy fields do - either only falling through to a broader-scoped policy when MergeType permits it, or documenting explicitly why RoutingType is a deliberate exception to MergeType's general semantics (if that's intentional).

Activity

  1. muwaqar-cflt commented on Jul 22, 2026

    @muwaqar-cflt
    ContributorAuthor

    cc @jukie @zirain @kkk777-7 @zhaohuabing
    this is a bug from #8173

  2. muwaqar-cflt commented on Jul 22, 2026

    @muwaqar-cflt
    ContributorAuthor

    tentatively assigning this to myself since i am fixing some additional indexes created in #9477 following similar pattern and think it would be easier if i can fix it along with them in one go.

  3. muwaqar-cflt commented on Jul 22, 2026

    @muwaqar-cflt
    ContributorAuthor

    /assign

  4. muwaqar-cflt commented on Jul 23, 2026

    @muwaqar-cflt
    ContributorAuthor

    Hi @jukie @zhaohuabing — I've put together a fix for this, but it turned out to also require introducing a shared precedence-resolution primitive that ended up fixing two other related bugs in BTPClusterSettingsIndex (MergeBackends cluster-merge eligibility #9477) along the way, plus migrating BTPLoadBalancerIndex/CTPClusterSettingsIndex onto the same primitive for consistency.

    Since #9477 is already a large, active PR, I didn't want to pile this on top of it. I've pushed the full change to a private branch so you can review it independently:

    muwaqar#4

    Plan, if the approach looks good to you:

    1. I'll split out a minimal version containing just the BackendTrafficPolicy RoutingType ignores MergeType, always inherits from broader-scoped policies #9541 fix (BTPRoutingTypeIndex + the primitive it needs) and open that as a real PR against envoyproxy/gateway main.
    2. Once that lands, I'll fold the remaining index migrations (BTPClusterSettingsIndex, BTPLoadBalancerIndex, CTPClusterSettingsIndex) into feat: add MergeBackends option for backend cluster deduplication #9477 itself, so feat: add MergeBackends option for backend cluster deduplication #9477 doesn't have to carry the primitive's introduction too.

    Would appreciate a look at the private PR whenever you get a chance — happy to adjust the split if you'd rather see it land differently.

  5. added this to the v1.9.0 Release milestone on Jul 29, 2026
  6. added a commit that references this issue on Jul 30, 2026
    9e09d12
  7. added a commit that references this issue on Aug 5, 2026
    a0ebf49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions