AlinsRan opened a new pull request, #2796: URL: https://github.com/apache/apisix-ingress-controller/pull/2796
## What this PR does `AttachBackendTrafficPolicyToUpstream` selected the `BackendTrafficPolicy` to apply by matching only `targetRef.Name`, ignoring `sectionName` (and `group`/`kind`). As a result: - a policy intended for a single named Service port was applied to the **whole Service** (all ports), and - a policy targeting a different resource kind with a colliding name (e.g. a `ServiceImport`) could attach to a `Service` backend. For a `Service` target, the Gateway API interprets `sectionName` as the **port name**. Attachment now honors it: - match the `targetRef` `group`/`kind` against the backend ref (applying Gateway API defaults: empty group = core, `Service` kind) before matching by name; - when `sectionName` is set, attach only to the backend whose resolved Service port name matches it; a port-specific `targetRef` takes **precedence** over a whole-Service one; - per Gateway API semantics, a `sectionName` that cannot be resolved does **not** attach. To resolve a backend's port name, the function now also receives the translate context's `Services` and maps the backend ref port number to the Service port name. All call sites (httproute / grpcroute / ingress / tcproute / tlsroute / udproute) are updated. ## Tests - Unit tests for the matching logic: sectionName match / mismatch / no-sectionName whole-Service / port-specific precedence / cross-kind rejection. - E2E test: route two hostnames to the same Service via its two named ports (`http`/80, `http-v2`/8080) and assert a `sectionName`-scoped policy attaches to exactly the matched per-port upstream — verified in **both** directions (sectionName `http-v2` → 8080 only; `http` → 80 only). `go build`, `go vet`, and the translator unit tests pass. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
