From d916dc40f35de859046993b2d3c3e173f8e2d96d Mon Sep 17 00:00:00 2001 From: Arko Dasgupta Date: Fri, 27 Sep 2024 11:58:07 -0700 Subject: [PATCH 1/2] set invalid Listener.SupportedKinds to empty list Fixes: https://github.com/envoyproxy/gateway/issues/4216 Relates to https://kubernetes.slack.com/archives/CR0H13KGA/p1727457195236889 Signed-off-by: Arko Dasgupta --- internal/gatewayapi/contexts.go | 4 +++- internal/gatewayapi/listener.go | 2 +- .../gateway-with-listener-with-unsupported-protocol.out.yaml | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/gatewayapi/contexts.go b/internal/gatewayapi/contexts.go index 7d6aee73d9..eee9ec4d6f 100644 --- a/internal/gatewayapi/contexts.go +++ b/internal/gatewayapi/contexts.go @@ -76,7 +76,9 @@ type ListenerContext struct { } func (l *ListenerContext) SetSupportedKinds(kinds ...gwapiv1.RouteGroupKind) { - l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds = kinds + l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds = make([]gwapiv1.RouteGroupKind, 0, len(kinds)) + l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds = + append(l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds, kinds...) } func (l *ListenerContext) IncrementAttachedRoutes() { diff --git a/internal/gatewayapi/listener.go b/internal/gatewayapi/listener.go index 724e835eb1..0c69d7b309 100644 --- a/internal/gatewayapi/listener.go +++ b/internal/gatewayapi/listener.go @@ -74,7 +74,7 @@ func (t *Translator) ProcessListeners(gateways []*GatewayContext, xdsIR resource case gwapiv1.UDPProtocolType: t.validateAllowedRoutes(listener, resource.KindUDPRoute) default: - listener.SetSupportedKinds(gwapiv1.RouteGroupKind{Kind: "InvalidKind"}) + listener.SetSupportedKinds() status.SetGatewayListenerStatusCondition(listener.gateway.Gateway, listener.listenerStatusIdx, gwapiv1.ListenerConditionAccepted, diff --git a/internal/gatewayapi/testdata/gateway-with-listener-with-unsupported-protocol.out.yaml b/internal/gatewayapi/testdata/gateway-with-listener-with-unsupported-protocol.out.yaml index 373c2f894c..0875ec2454 100644 --- a/internal/gatewayapi/testdata/gateway-with-listener-with-unsupported-protocol.out.yaml +++ b/internal/gatewayapi/testdata/gateway-with-listener-with-unsupported-protocol.out.yaml @@ -34,8 +34,7 @@ gateways: status: "True" type: ResolvedRefs name: unsupported - supportedKinds: - - kind: InvalidKind + supportedKinds: [] httpRoutes: - apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute From a98573dd9c239e62d780adf2d9c16e273592e49b Mon Sep 17 00:00:00 2001 From: Arko Dasgupta Date: Fri, 27 Sep 2024 12:14:17 -0700 Subject: [PATCH 2/2] lint Signed-off-by: Arko Dasgupta --- internal/gatewayapi/contexts.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/gatewayapi/contexts.go b/internal/gatewayapi/contexts.go index eee9ec4d6f..fbd4c588f9 100644 --- a/internal/gatewayapi/contexts.go +++ b/internal/gatewayapi/contexts.go @@ -77,8 +77,7 @@ type ListenerContext struct { func (l *ListenerContext) SetSupportedKinds(kinds ...gwapiv1.RouteGroupKind) { l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds = make([]gwapiv1.RouteGroupKind, 0, len(kinds)) - l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds = - append(l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds, kinds...) + l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds = append(l.gateway.Status.Listeners[l.listenerStatusIdx].SupportedKinds, kinds...) } func (l *ListenerContext) IncrementAttachedRoutes() {