mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
fix(platform): keep tenant Gateways off an unserved class on cozyplane
The guard against the bundled cilium GatewayClass on the cozyplane variant compared the raw gateway.className, while apps.yaml trims it and defaults an empty one to cilium before tenants see it, so "" and " cilium " passed and still resolved to a class nothing serves. It also ran only for the platform's gateway flag: a tenant enabling its own Gateway never reached it. The platform guard now compares the resolved class. For the tenant path, the platform lists the classes no controller serves in _cluster.gateway-unserved-classes, cilium on cozyplane, and the gateway chart refuses a resolved class in that list, whether the tenant chose it or inherited the default. Classes the operator makes selectable keep working. Assisted-by: LLM Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
This commit is contained in:
1 parent
d15fb0fc35
commit
e6d7671b19
6 files changed
+140
-2
No files matched your search
@@ -249,6 +249,10 @@ stringData:
|
||||
{{- end }}
|
||||
gateway-edge-classes: {{ $edgeClasses | join "," | quote }}
|
||||
gateway-tenant-classes: {{ $tenantClasses | join "," | quote }}
|
||||
{{- /* GatewayClasses no controller on this cluster serves. The bundled
|
||||
cilium class has none on the cozyplane networking variant, and a
|
||||
tenant Gateway on it would never program. */}}
|
||||
gateway-unserved-classes: {{ ternary "cilium" "" (eq (.Values.bundles.system.networkingVariant | default "kubeovn-cilium") "cozyplane") | quote }}
|
||||
{{- /* Whether the root tenant hosts the platform monitoring stack
|
||||
(Tenant/root spec.monitoring). cozystack-basics gates the
|
||||
cozy-monitoring -> tenant-root vlinsert/vminsert ExternalName
|
||||
|
||||
@@ -11,8 +11,12 @@
|
||||
{{- end -}}
|
||||
{{- /* The default gateway.className is the Cilium class, and no Cilium runs on
|
||||
the cozyplane variant — every tenant Gateway would sit unserved with
|
||||
nothing reporting why. */ -}}
|
||||
{{- if and (eq $nv "cozyplane") .Values.gateway.enabled (eq .Values.gateway.className "cilium") -}}
|
||||
nothing reporting why. Compared after the normalization apps.yaml
|
||||
applies before handing the class to tenants, so an empty or padded
|
||||
value cannot slip past. A tenant enabling its own Gateway is refused in
|
||||
the gateway chart, through _cluster.gateway-unserved-classes. */ -}}
|
||||
{{- $resolvedGatewayClass := .Values.gateway.className | default "" | toString | trim | default "cilium" -}}
|
||||
{{- if and (eq $nv "cozyplane") .Values.gateway.enabled (eq $resolvedGatewayClass "cilium") -}}
|
||||
{{- fail "gateway.enabled needs a gateway.className another implementation serves on the cozyplane networking variant: nothing serves the \"cilium\" class there" -}}
|
||||
{{- end -}}
|
||||
{{- if .Values.bundles.system.enabled }}
|
||||
|
||||
@@ -142,3 +142,22 @@ tests:
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s*gateway-tenant-classes:\s*""'
|
||||
|
||||
# The gateway chart refuses a resolved class in this list, which is how a
|
||||
# tenant that enables its own Gateway is kept off a class nothing serves.
|
||||
- it: marks the cilium class unserved on the cozyplane variant
|
||||
set:
|
||||
bundles:
|
||||
system:
|
||||
networkingVariant: cozyplane
|
||||
asserts:
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s*gateway-unserved-classes:\s*"cilium"'
|
||||
|
||||
- it: marks no class unserved on the default variant
|
||||
asserts:
|
||||
- matchRegex:
|
||||
path: stringData["values.yaml"]
|
||||
pattern: '(?m)^\s*gateway-unserved-classes:\s*""'
|
||||
|
||||
@@ -402,3 +402,34 @@ tests:
|
||||
kind: Package
|
||||
name: cozystack.cozyplane-apiserver
|
||||
any: true
|
||||
|
||||
# apps.yaml trims the class and defaults an empty one to cilium before
|
||||
# tenants see it, so the guard compares the same resolved value.
|
||||
- it: refuses an empty gateway class on cozyplane
|
||||
set:
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
networkingVariant: cozyplane
|
||||
gateway:
|
||||
enabled: true
|
||||
className: ""
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: 'nothing serves the "cilium" class'
|
||||
|
||||
- it: refuses a padded cilium gateway class on cozyplane
|
||||
set:
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
networkingVariant: cozyplane
|
||||
gateway:
|
||||
enabled: true
|
||||
className: " cilium "
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: 'nothing serves the "cilium" class'
|
||||
|
||||
@@ -34,6 +34,13 @@
|
||||
{{- end }}
|
||||
{{- $defaultClass := $rawDefaultClass | trim | default "cilium" }}
|
||||
{{- $className := $rawClassName | trim | default $defaultClass }}
|
||||
{{- /* Checked for the resolved class, so it holds whether the tenant chose
|
||||
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) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $edgeClasses := list }}
|
||||
{{- range splitList "," ((index .Values._cluster "gateway-edge-classes") | default "") }}
|
||||
{{- $c := . | trim }}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
suite: a tenant Gateway refuses a class nothing serves
|
||||
templates:
|
||||
- templates/tenantgateway.yaml
|
||||
|
||||
# On the cozyplane networking variant no controller serves the bundled cilium
|
||||
# class, and the platform says so in _cluster.gateway-unserved-classes. The
|
||||
# check runs on the resolved class, so it holds whether the tenant chose it or
|
||||
# inherited the platform default, and whatever the platform's own gateway flag.
|
||||
release:
|
||||
name: gateway
|
||||
namespace: tenant-alice
|
||||
|
||||
tests:
|
||||
- it: refuses an inherited default class nothing serves
|
||||
set:
|
||||
_cluster:
|
||||
solver: http01
|
||||
expose-ingress: tenant-root
|
||||
issuer-name: letsencrypt-prod
|
||||
gateway-class-name: cilium
|
||||
gateway-unserved-classes: cilium
|
||||
_namespace:
|
||||
host: alice.example.org
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: 'GatewayClass "cilium" has no controller on this cluster'
|
||||
|
||||
- it: refuses a tenant-chosen class nothing serves
|
||||
set:
|
||||
_cluster:
|
||||
solver: http01
|
||||
expose-ingress: tenant-root
|
||||
issuer-name: letsencrypt-prod
|
||||
gateway-class-name: envoy
|
||||
gateway-tenant-classes: cilium
|
||||
gateway-unserved-classes: cilium
|
||||
_namespace:
|
||||
host: alice.example.org
|
||||
gatewayClassName: cilium
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: 'GatewayClass "cilium" has no controller on this cluster'
|
||||
|
||||
- it: lets a tenant select a served class while the default is unserved
|
||||
set:
|
||||
_cluster:
|
||||
solver: http01
|
||||
expose-ingress: tenant-root
|
||||
issuer-name: letsencrypt-prod
|
||||
gateway-class-name: cilium
|
||||
gateway-tenant-classes: envoy
|
||||
gateway-unserved-classes: cilium
|
||||
_namespace:
|
||||
host: alice.example.org
|
||||
gatewayClassName: envoy
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.gatewayClassName
|
||||
value: envoy
|
||||
|
||||
- it: renders the cilium class where nothing marks it unserved
|
||||
set:
|
||||
_cluster:
|
||||
solver: http01
|
||||
expose-ingress: tenant-root
|
||||
issuer-name: letsencrypt-prod
|
||||
gateway-class-name: cilium
|
||||
_namespace:
|
||||
host: alice.example.org
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.gatewayClassName
|
||||
value: cilium
|
||||
Reference in new issue
Block a user