Repository navigation
fix(gatewayapi): don't skip MergeBackends precedence-index claims for policies that set nothing - #9590
Conversation
✅ Deploy Preview for cerulean-figolla-1f9435 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #9590 +/- ##
==========================================
+ Coverage 76.02% 76.05% +0.02%
==========================================
Files 259 261 +2
Lines 43275 43420 +145
==========================================
+ Hits 32900 33022 +122
- Misses 8183 8194 +11
- Partials 2192 2204 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
LGTM, thanks! |
|
/retest |
…ergeType is unset Fixes envoyproxy#9541: a route-rule/route-targeted BackendTrafficPolicy with both RoutingType and MergeType unset incorrectly inherited RoutingType from its resolved gateway/listener parent. MergeType nil means the policy doesn't merge with a parent at all, so it must resolve to its own (nil) value instead. Migrates BTPRoutingTypeIndex onto a new, generic policyIndex[T] primitive that reuses the existing policyScope type (previously used only by SecurityPolicy's override/merge tracking), rather than patching the old ad hoc btpRoutingKey-based maps directly. Each entry carries a single effective bool decided at write time - via isRouteEffective's MergeType-aware rule for route-rule/route scopes, or the caller-supplied hasValue for listener/gateway scopes - so Lookup resolves any scope uniformly. policyScope gains a RouteKind tag (a 1-byte enum, to keep the struct under gocritic's hugeParam threshold) so route-rule/route scopes targeting different route kinds under the same name never collide. Signed-off-by: Muhammad Waqar <[email protected]>
…et fix Signed-off-by: Muhammad Waqar <[email protected]>
811b558 to
9e073e9
Compare
…ngs, LoadBalancer, and ClientTrafficPolicy Applies the same "every accepted policy must claim its precedence slot, even one that sets nothing" fix from BTPRoutingTypeIndex to BTPClusterSettingsIndex, BTPLoadBalancerIndex, and the newly-migrated CTPClusterSettingsIndex, closing the same class of bug for envoyproxy#9588. All three indexes are now built on the shared policyIndex[T] primitive instead of ad-hoc raw maps, and the BTP indexes gained ListenerSet support. Signed-off-by: Muhammad Waqar <[email protected]>
|
@codex review |
….go and its test The test file had grown its own copy of route.go's listener-scope-checking loop just to keep compiling after CTPClusterSettingsIndex became a plain policyIndex alias, so the test wasn't actually exercising production code and could silently drift from it. Extract the loop into a package function both call. Signed-off-by: Muhammad Waqar <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e4ccd881f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…onally The LoadBalancer switch only ran under `if hasLoadBalancer`, so an accepted Gateway-wide BTP that left LoadBalancer unset skipped claiming its slot entirely - letting a younger conflicting BTP that does set ConsistentHash win it. Same "must claim slot unconditionally" fix already applied to RoutingType and ClusterSettings. Found via automated PR review on envoyproxy#9590. Signed-off-by: Muhammad Waqar <[email protected]>
|
A note on scope: this PR originally targeted So the scope here is intentionally wider than the original description, now covering #9541 and #9588. For 1.8.4 (which doesn't have MergeBackends' ClusterSettings/LoadBalancer/CTP indexes at all), a separate, isolated fix scoped to |
…aliasing Go won't allow new methods on a type alias to an instantiated generic (the reason these indexes were reduced to plain policyIndex[T] aliases), but a struct that anonymously embeds *policyIndex[T] is a distinct named type, so it can have its own methods. This restores BTPRoutingTypeIndex.LookupBTPRoutingType/LookupGatewayBTRoutingType, BTPClusterSettingsIndex.HasRouteLevelClusterSettings, BTPLoadBalancerIndex.IsConsistentHash, and CTPClusterSettingsIndex.HasListenerLevelClusterSettings - matching main's PR #4 design - while keeping call sites free of any .index field indirection: because the embed is anonymous, methods forward via promotion (idx.Lookup(...), not idx.index.Lookup(...)). Each dedicated method checks for a nil receiver before touching the embedded field, so nil-safety doesn't regress. Signed-off-by: Muhammad Waqar <[email protected]>
…omments - Port TestCTPClusterSettingsIndex's 2 missing oldest-accepted-blocks- younger regression cases (Gateway-listener and ListenerSet-wide level), matching the same coverage already ported for BTP indexes. - Port the missing mergebackends-http-demerge-route-replaces-gateway- cluster-settings golden fixture pair, verified byte-identical to PR #4's own validated output (aside from the mergeBackends schema drift already fixed in the other 3 ported fixtures). - Strip every test-case comment added by this PR (per review feedback); comments already present before this PR are left untouched. - Merge TestPolicyIndexLookupListenerSet into TestPolicyIndexLookup for consistency with TestPolicyIndexLookupExact's single-table style, and settle on a consistent useRuleName/useListener/useListenerSet naming convention for the three optional Lookup arguments. Signed-off-by: Muhammad Waqar <[email protected]>
|
/retest |
… via hasRouteLevelClusterSettings The route/rule-level BackendTrafficPolicy conflict this TODO described is already excluded from cluster merging by hasRouteLevelClusterSettings's pinned-slot tracking, so it never reaches x.BackendClusters here. Signed-off-by: Muhammad Waqar <[email protected]>
…dence fix MergeBackends itself hasn't shipped in a release yet, so a separate bug-fix note in the same release cycle as its own new-feature note is redundant and confusing. Signed-off-by: Muhammad Waqar <[email protected]>
…thods for clarity Fold BTPClusterSettingsIndex.HasRouteLevelClusterSettings and CTPClusterSettingsIndex.HasListenerLevelClusterSettings's callers into a single hasClusterSettingsBelowGateway, and rename all three consistently to describe what they answer (whether cluster-scoped settings are defined below Gateway scope) rather than the mechanism. Harmonize policyIndex's internal value-naming (pinned -> replacesParent) and give resolveEntry's counterpart a matching resolveParentLevels name. Move the TODO(envoyproxy#9619) ListenerSet-attachment gap note from the read-side doc comment to the write-side switch-cases in BuildBTPIndexes that actually lack ListenerSet support. Signed-off-by: Muhammad Waqar <[email protected]>
…cope setListenerSetLevel hardcoded effective:true unconditionally, unlike its Gateway-listener counterpart setGatewayListenerLevel. This blocked a bare-ListenerSet-targeted policy that leaves a field unset from falling through to the Gateway's setting, even though resolveParentLevels's final step (a bare gatewayScope lookup) is not actually skipped for ListenerSet-attached routes - only the Gateway-listener scope is, since Gateway listeners and ListenerSet listeners are true siblings. Thread BTPRoutingTypeIndex's existing hasRoutingType signal through to fix the one caller (routingTypeIdx) where this was user-visible; CTP's caller is unaffected since it always intends hasValue true. Also correct the Lookup/setListenerSetLevel doc comments, which overstated the skip as covering "gateway" scope generally instead of just the Gateway-listener level specifically. Signed-off-by: Muhammad Waqar <[email protected]>
|
/retest |
|
/retest |
What this PR does / why we need it:
MergeBackends' precedence-resolution indexes for
BackendTrafficPolicy(RoutingType, cluster-scoped settings eligibility,LoadBalancerConsistentHash) andClientTrafficPolicy(cluster-scoped settings eligibility) all shared the same bug: population logic skipped any accepted policy that set nothing at its target, regardless ofmergeType. For a route-rule/route-targeted BTP withmergeTypealso unset (meaning it doesn't merge with any parent at all), this let the lookup silently fall through to a broader listener/gateway policy's settings instead of resolving to the rule's own (empty) default - or let a skipped policy's target slot be silently claimed by a younger, conflicting policy instead.This migrates all of
BTPRoutingTypeIndex,BTPClusterSettingsIndex,BTPLoadBalancerIndex, and the newly-introducedCTPClusterSettingsIndexonto a shared, minimalpolicyIndex[T]primitive built on the existingpolicyScopetype (already used bySecurityPolicy's override/merge tracking), rather than patching the old ad hoc raw-map-based indexes directly. Every accepted policy now claims its precedence slot unconditionally (even when it sets nothing), preserving the existing "oldest accepted policy wins over a younger conflicting one" guarantee - dedicated tests cover this at route-rule/route/listener/gateway/ListenerSet level for each index.policyScopegains aRouteKindtag (a 1-byte enum, to keep the struct undergocritic'shugeParamthreshold) so route-rule/route scopes targeting different route kinds under the same name never collide. The BTP indexes also gained ListenerSet-attach support (Gateway/Listener/ListenerSet/ListenerSet-listener levels), extending #9419/#9425's ListenerSet-for-BTP work to this precedence layer.Out of scope: #9619 (ClusterSettings/LoadBalancer indexes don't yet track ListenerSet-level BTP attachment the way
RoutingTypenow does) is a related but separate gap, left for a follow-up.Which issue(s) this PR fixes:
Fixes #9541
Fixes #9588
PR Checklist
git commit -s)./api.go build ./...,go vet ./...,gofmt -l,make lint.golint, andgo test ./...all pass.make gen-checkshows no drift beyond this PR's own changes.backendtrafficpolicy_test.go,clienttrafficpolicy_test.go, and a newpolicyindex_test.gocovering the shared primitive directly (including oldest-accepted-vs-younger-conflicting-policy cases at every level), plus three new golden translator fixtures.release-notes/current/bug_fixes/9541-9588-mergebackends-precedence-index-early-exit.md.BTPRoutingTypeIndex,BTPClusterSettingsIndex,BTPLoadBalancerIndex,CTPClusterSettingsIndex); no breaking changes.