From 6da59b7ed085f12840b36b2c7223a17cd8c53493 Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Fri, 20 Nov 2026 00:32:01 +0100 Subject: [PATCH] fix(gateway): give the remedy for an unserved class A tenant that chose the unserved class itself cannot fix the render by asking the operator to change the platform default: its own choice wins. Tell it to change or clear tenant.spec.gatewayClass instead. Assisted-by: LLM Signed-off-by: Timofei Larkin --- packages/extra/gateway/templates/tenantgateway.yaml | 6 +++++- packages/extra/gateway/tests/unserved_class_test.yaml | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/extra/gateway/templates/tenantgateway.yaml b/packages/extra/gateway/templates/tenantgateway.yaml index 5438a898b..7bec4934a 100644 --- a/packages/extra/gateway/templates/tenantgateway.yaml +++ b/packages/extra/gateway/templates/tenantgateway.yaml @@ -38,7 +38,11 @@ the class or inherited the platform default. */}} {{- range splitList "," ((index .Values._cluster "gateway-unserved-classes") | default "") }} {{- if eq (trim .) $className }} - {{- fail (printf "packages/extra/gateway: GatewayClass %q has no controller on this cluster, so this Gateway would never be programmed. Set tenant.spec.gatewayClass to a class the operator lists in gateway.tenantSelectableClasses, or have the operator set gateway.className to a served class." $className) }} + {{- $remedy := "Set tenant.spec.gatewayClass to a served class the operator lists in gateway.tenantSelectableClasses, or have the operator set gateway.className to a served class." }} + {{- if trim $rawClassName }} + {{- $remedy = "Change tenant.spec.gatewayClass to a served class the operator lists in gateway.tenantSelectableClasses, or clear it to take the platform default if that class is served." }} + {{- end }} + {{- fail (printf "packages/extra/gateway: GatewayClass %q has no controller on this cluster, so this Gateway would never be programmed. %s" $className $remedy) }} {{- end }} {{- end }} {{- $edgeClasses := list }} diff --git a/packages/extra/gateway/tests/unserved_class_test.yaml b/packages/extra/gateway/tests/unserved_class_test.yaml index e5c0addd2..565f7340e 100644 --- a/packages/extra/gateway/tests/unserved_class_test.yaml +++ b/packages/extra/gateway/tests/unserved_class_test.yaml @@ -23,7 +23,7 @@ tests: host: alice.example.org asserts: - failedTemplate: - errorPattern: 'GatewayClass "cilium" has no controller on this cluster' + errorPattern: 'GatewayClass "cilium" has no controller on this cluster.*have the operator set gateway.className' - it: refuses a tenant-chosen class nothing serves set: @@ -39,7 +39,7 @@ tests: gatewayClassName: cilium asserts: - failedTemplate: - errorPattern: 'GatewayClass "cilium" has no controller on this cluster' + errorPattern: 'GatewayClass "cilium" has no controller on this cluster.*Change tenant.spec.gatewayClass .* or clear it' - it: lets a tenant select a served class while the default is unserved set: