AlinsRan commented on code in PR #2804:
URL:
https://github.com/apache/apisix-ingress-controller/pull/2804#discussion_r3654538174
##########
internal/adc/translator/translator.go:
##########
@@ -66,6 +66,27 @@ func hasExplicitListenerTarget(parentRefs
[]gatewayv1.ParentReference) bool {
return false
}
+// collectServerPortMatchPorts returns the set of listener ports that should be
+// enforced through a server_port var.
+//
+// Listeners carrying a hostname are isolated by that hostname (service.hosts),
+// which is the correct discriminator when several listeners share a single
port.
+// A server_port var adds no isolation for them and actively breaks routing: it
+// pins the route to the Gateway's declared listener port, which need not equal
+// the port APISIX actually accepts the connection on (node_listen), turning
+// every request into a 404. Only hostname-less listeners rely on port-based
+// isolation, so only their ports contribute here.
+func collectServerPortMatchPorts(listeners []gatewayv1.Listener)
map[int32]struct{} {
+ ports := make(map[int32]struct{})
+ for _, listener := range listeners {
+ if listener.Hostname != nil && *listener.Hostname != "" {
Review Comment:
Correction + actual fix. My earlier replies here were wrong on two counts:
this scenario was **not** actually fixed, and the default mode is `auto`, not
`off` — so `auto`/`explicit` both emit `server_port == 80` and drop the traffic
arriving on the hostname listener's port, exactly as you described.
Fixed properly in 9b4219d4 by splitting the two concerns:
- **Decision** (whether to inject at all) still uses hostname-less listener
ports, so a route bound only to hostname listeners injects nothing and
`HTTPRouteListenerHostnameMatching` stays green.
- **Predicate value**, once injecting, now lists *every* targeted listener
port (`allListenerPorts`), so a route attached to both a hostname-less and a
hostname listener matches on both — `server_port in [80, 8080]` instead of `==
80`.
This is your option (a). Splitting routes per listener (b) remains the
cleaner long-term model for real `GatewayHTTPListenerIsolation` support, but
(a) removes the traffic-drop without that surgery. Test
`TestTranslateHTTPRouteServerPortVarsByMode` updated — the mixed-listener case
previously asserted the buggy single-port predicate.
--
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]