fix(platform): stop handing tenants a root S3 the root tenant does not run

cozystack-basics wrote seaweedfs: tenant-root into the root values
unconditionally, so every tenant without its own SeaweedFS inherited
tenant-root as its S3 even when Tenant/root runs none. A Bucket there got
a BucketClaim for a bucket class that never appears, and Harbor got its
registry bucket the same way.

seaweedfs.rootEnabled records that choice the way monitoring.rootEnabled
does for monitoring, and the bucket and harbor charts refuse to render
without S3 up the tenant chain rather than wait on a class that does not
exist.

Older configurations have no SeaweedFS flag. Keep their root S3 enabled.
For an explicit value only true or the string "true" enables it.

Assisted-by: LLM
Signed-off-by: Yan Bondarenko <202671653+yankawai@users.noreply.github.com>
This commit is contained in:
Yan Bondarenko committed 2026-12-02 07:11:22 +01:00
1 parent 15126f27ca
commit 19ab55c030
16 files changed
+188 -24

No files matched your search

+6 -6
View File
@@ -286,7 +286,7 @@ persistentvolumeclaim/db-qdrant-test-0'
tmp=$(mktemp -d)
write_fake_kubectl "$tmp"
render_hook "$HARBOR_CHART" harbor-test tenant-test harbor-test-cleanup "$tmp/hook.sh" \
--set '_namespace.host=example.org' --set '_cluster.solver=http01'
--set '_namespace.host=example.org' --set '_namespace.seaweedfs=tenant-root' --set '_cluster.solver=http01'
export KLOG="$tmp/calls"
export CHALLENGE_LIST='harbor-test-cert-1 '
@@ -322,7 +322,7 @@ persistentvolumeclaim/db-qdrant-test-0'
tmp=$(mktemp -d)
write_fake_kubectl "$tmp"
render_hook "$HARBOR_CHART" harbor-test tenant-test harbor-test-cleanup "$tmp/hook.sh" \
--set '_namespace.host=example.org' --set '_cluster.solver=http01'
--set '_namespace.host=example.org' --set '_namespace.seaweedfs=tenant-root' --set '_cluster.solver=http01'
export KLOG="$tmp/calls"
export CHALLENGE_LIST=''
@@ -350,7 +350,7 @@ persistentvolumeclaim/db-qdrant-test-0'
tmp=$(mktemp -d)
write_fake_kubectl "$tmp"
render_hook "$HARBOR_CHART" harbor-test tenant-test harbor-test-cleanup "$tmp/hook.sh" \
--set '_namespace.host=example.org' --set '_cluster.solver=http01'
--set '_namespace.host=example.org' --set '_namespace.seaweedfs=tenant-root' --set '_cluster.solver=http01'
export KLOG="$tmp/calls"
export CHALLENGE_LIST='harbor-test-cert-1 '
@@ -396,7 +396,7 @@ persistentvolumeclaim/db-qdrant-test-0'
tmp=$(mktemp -d)
write_fake_kubectl "$tmp"
render_hook "$HARBOR_CHART" harbor-test tenant-test harbor-test-cleanup "$tmp/hook.sh" \
--set '_namespace.host=example.org' --set '_cluster.solver=http01'
--set '_namespace.host=example.org' --set '_namespace.seaweedfs=tenant-root' --set '_cluster.solver=http01'
export KLOG="$tmp/calls"
export CHALLENGE_LIST='harbor-test-cert-1 '
@@ -438,7 +438,7 @@ persistentvolumeclaim/db-qdrant-test-0'
tmp=$(mktemp -d)
write_fake_kubectl "$tmp"
render_hook "$HARBOR_CHART" harbor-test tenant-test harbor-test-cleanup "$tmp/hook.sh" \
--set '_namespace.host=example.org' --set '_cluster.solver=http01'
--set '_namespace.host=example.org' --set '_namespace.seaweedfs=tenant-root' --set '_cluster.solver=http01'
export KLOG="$tmp/calls"
export CHALLENGE_LIST='harbor-test-cert-1 '
@@ -480,7 +480,7 @@ persistentvolumeclaim/db-qdrant-test-0'
tmp=$(mktemp -d)
write_fake_kubectl "$tmp"
render_hook "$HARBOR_CHART" harbor-test tenant-test harbor-test-cleanup "$tmp/hook.sh" \
--set '_namespace.host=example.org' --set '_cluster.solver=http01'
--set '_namespace.host=example.org' --set '_namespace.seaweedfs=tenant-root' --set '_cluster.solver=http01'
export KLOG="$tmp/calls"
export CHALLENGE_LIST=''
+2
View File
@@ -25,6 +25,8 @@ render_chart() {
tenant) set -- tenant-sub --api-versions v1.edp.epam.com/v1 ;;
# Satisfy the parent-cluster and release-name contract before the lookup.
kubernetes-nodes) set -- kubernetes-nodes-render-check --set-string cluster=render ;;
# Both refuse to render without S3 up the tenant chain.
bucket|harbor) set -- "$name-render-check" --set-string _namespace.seaweedfs=tenant-root ;;
*) set -- "$name-render-check" ;;
esac
helm template "$@" "$chart" -n tenant-test -f "$fixture"
+1
View File
@@ -57,6 +57,7 @@ render() {
bootbox) set -- bootbox; namespace=tenant-root ;;
computeplane|etcd|info|ingress|monitoring|seaweedfs|gateway) set -- "$name" ;;
external-dns) set -- external-dns --set provider=inmemory ;;
bucket|harbor) set -- "$name-render-check" --set-string _namespace.seaweedfs=tenant-root ;;
kubernetes-nodes) set -- kubernetes-nodes-render-check --set-string cluster=render \
--set-string resources.cpu=2 --set-string resources.memory=4Gi ;;
tenant) set -- tenant-sub --api-versions v1.edp.epam.com/v1 ;;
+1 -1
View File
@@ -14,7 +14,7 @@ The source of `_cluster` is `packages/core/platform/templates/apps.yaml`; `_name
| `configured.yaml` | OIDC on, per-host ACME via http01, shared services and topology constraint |
| `wildcard.yaml` | OIDC on, dns01 with a platform-issued wildcard certificate, shared services and topology constraint |
Each chart is attempted under every fixture. `vm-instance` and `kubernetes-nodes` require a `VirtualMachineClusterInstancetype` lookup on their defaults. The sweep accepts their skip only while every fixture fails with the recorded lookup diagnostic; a successful render or a different error fails the sweep. For kubernetes-nodes it supplies a parent cluster and matching release name first. For tenant it declares the Keycloak API with `--api-versions v1.edp.epam.com/v1`, allowing OIDC-enabled fixtures to render the realm groups.
Each chart is attempted under every fixture. `vm-instance` and `kubernetes-nodes` require a `VirtualMachineClusterInstancetype` lookup on their defaults. The sweep accepts their skip only while every fixture fails with the recorded lookup diagnostic; a successful render or a different error fails the sweep. For kubernetes-nodes it supplies a parent cluster and matching release name first. For bucket and harbor it names a SeaweedFS namespace, since both refuse to render without S3 up the tenant chain. For tenant it declares the Keycloak API with `--api-versions v1.edp.epam.com/v1`, allowing OIDC-enabled fixtures to render the realm groups.
`lookup` returns an empty result during this check. Tests for existing objects belong in chart-specific helm-unittest suites using `kubernetesProvider`; `packages/apps/clickhouse/tests/backup_api_password_persistence_test.yaml` covers both password generation and preservation that way. Presets, replica counts and other app feature toggles are outside this sweep.
@@ -1,4 +1,7 @@
{{- $seaweedfs := .Values._namespace.seaweedfs }}
{{- if not $seaweedfs }}
{{- fail "a bucket needs S3, and neither this tenant nor a tenant above it runs SeaweedFS" }}
{{- end }}
{{- $pool := .Values.storagePool }}
{{- /*
COSI classes are cluster-scoped and named after the namespace of the instance
@@ -0,0 +1,25 @@
suite: bucket needs an S3 backend in its tenant chain
templates:
- templates/bucketclaim.yaml
release:
name: my-bucket
namespace: tenant-demo
tests:
- it: claims the bucket class of the nearest tenant with SeaweedFS
set:
_namespace:
seaweedfs: tenant-root
asserts:
- equal:
path: spec.bucketClassName
value: tenant-root
- it: refuses to render when no tenant up the chain runs SeaweedFS
set:
_namespace:
seaweedfs: ""
asserts:
- failedTemplate:
errorPattern: "a bucket needs S3, and neither this tenant nor a tenant above it runs SeaweedFS"
@@ -1,4 +1,7 @@
{{- $seaweedfs := .Values._namespace.seaweedfs }}
{{- if not $seaweedfs }}
{{- fail "harbor keeps images in S3, and neither this tenant nor a tenant above it runs SeaweedFS" }}
{{- end }}
apiVersion: objectstorage.k8s.io/v1alpha1
kind: BucketClaim
metadata:
@@ -0,0 +1,28 @@
suite: harbor needs an S3 backend in its tenant chain
templates:
- templates/bucket.yaml
release:
name: harbor
namespace: tenant-demo
tests:
- it: claims the registry bucket from the nearest tenant with SeaweedFS
set:
_namespace:
seaweedfs: tenant-root
documentSelector:
path: kind
value: BucketClaim
asserts:
- equal:
path: spec.bucketClassName
value: tenant-root
- it: refuses to render when no tenant up the chain runs SeaweedFS
set:
_namespace:
seaweedfs: ""
asserts:
- failedTemplate:
errorPattern: "harbor keeps images in S3, and neither this tenant nor a tenant above it runs SeaweedFS"
@@ -290,6 +290,7 @@ stringData:
(Tenant/root spec.ingress). `dig`, as for monitoring-enabled
above, so an explicit false survives. */}}
ingress-enabled: {{ dig "rootEnabled" true (.Values.ingress | default dict) | quote }}
seaweedfs-enabled: {{ dig "rootEnabled" true (.Values.seaweedfs | default dict) | quote }}
{{- /* The rate each shared-central tracing tenant's collector holds it
to. Only written when set: every release in every tenant reads
this Secret, and a key appearing would upgrade all of them. */}}
@@ -0,0 +1,30 @@
suite: apps.yaml wires seaweedfs.rootEnabled into _cluster
templates:
- templates/apps.yaml
release:
name: cozy-platform
namespace: cozy-system
tests:
- it: writes seaweedfs-enabled true by default
asserts:
- matchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s*seaweedfs-enabled:\s*"true"'
- it: writes seaweedfs-enabled false when seaweedfs.rootEnabled is disabled
set:
seaweedfs.rootEnabled: false
asserts:
- matchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s*seaweedfs-enabled:\s*"false"'
- it: falls back to true (no panic) when seaweedfs is null
set:
seaweedfs: null
asserts:
- matchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s*seaweedfs-enabled:\s*"true"'
@@ -26,3 +26,7 @@ bundles:
# into it would dead-end; see monitoring.rootEnabled in values.yaml.
monitoring:
rootEnabled: false
# Tenant/root does not run SeaweedFS here either, so tenants must not take it
# as their S3. See seaweedfs.rootEnabled in values.yaml.
seaweedfs:
rootEnabled: false
@@ -31,3 +31,7 @@ bundles:
# into it would dead-end; see monitoring.rootEnabled in values.yaml.
monitoring:
rootEnabled: false
# Tenant/root does not run SeaweedFS here either, so tenants must not take it
# as their S3. See seaweedfs.rootEnabled in values.yaml.
seaweedfs:
rootEnabled: false
@@ -31,3 +31,7 @@ bundles:
# into it would dead-end; see monitoring.rootEnabled in values.yaml.
monitoring:
rootEnabled: false
# Tenant/root does not run SeaweedFS here either, so tenants must not take it
# as their S3. See seaweedfs.rootEnabled in values.yaml.
seaweedfs:
rootEnabled: false
+7
View File
@@ -835,6 +835,13 @@ ingress:
# to keep the value existing clusters already render.
rootEnabled: true
# Platform object storage configuration.
seaweedfs:
# Whether the root tenant (tenant-root) runs SeaweedFS, i.e. Tenant/root
# spec.seaweedfs=true. Tenants without their own SeaweedFS take tenant-root
# as their S3 only when this is true. Keep it in sync with Tenant/root
# spec.seaweedfs, the default true preserves the historical behaviour.
rootEnabled: true
# Platform monitoring configuration.
monitoring:
# Whether the root tenant (tenant-root) hosts the platform
@@ -23,8 +23,8 @@ stringData:
{{- if or (kindIs "invalid" $ingress) (eq (toString $ingress) "true") }}
ingress: tenant-root
{{- end }}
{{- /* `gateway` is conditional, the other four `_namespace` keys are
unconditional. The `apps/tenant` chart gates tenant-root via
{{- /* `gateway`, `ingress` and `seaweedfs` are conditional, `etcd` and
`monitoring` are unconditional. The `apps/tenant` chart gates tenant-root via
`ne (include "tenant.name" .) "tenant-root"`, so the namespace.yaml
propagation fix that consumes `tenant.gatewayEffective` never
reaches tenant-root — and the `cozystack-values` Secret rendered
@@ -42,4 +42,7 @@ stringData:
gateway: tenant-root
{{- end }}
monitoring: tenant-root
{{- $seaweedfs := dig "seaweedfs-enabled" true (.Values._cluster | default dict) }}
{{- if eq (toString $seaweedfs) "true" }}
seaweedfs: tenant-root
{{- end }}
@@ -19,16 +19,17 @@ set:
# never reaches tenant-root — this Secret is the only place that
# value gets set for the root tenant.
#
# Three of the five `_namespace.*` keys (`etcd`, `monitoring`,
# `seaweedfs`) are always rendered, because their dependent platform
# apps are always installable in tenant-root. `gateway` is conditional
# on `_cluster.gateway-enabled`: when the platform-level flag is false
# (the default), Gateway is not installed, and writing
# `gateway: tenant-root` would point apps at a Gateway that doesn't
# exist. `ingress` is conditional on `_cluster.ingress-enabled` for the
# same reason: with ingress off on the root Tenant there is no
# ingress-nginx-system in tenant-root, and seaweedfs would wait on it
# forever. The fixtures below pin both halves of each contract.
# Two of the five `_namespace.*` keys (`etcd`, `monitoring`) are always
# rendered, because their dependent platform apps are always installable
# in tenant-root. `gateway` is conditional on `_cluster.gateway-enabled`:
# when the platform-level flag is false (the default), Gateway is not
# installed, and writing `gateway: tenant-root` would point apps at a
# Gateway that doesn't exist. `ingress` is conditional on
# `_cluster.ingress-enabled` for the same reason: with ingress off on the
# root Tenant there is no ingress-nginx-system in tenant-root, and
# seaweedfs would wait on it forever. `seaweedfs` follows
# `_cluster.seaweedfs-enabled`, so tenants do not inherit an S3 the root
# tenant does not run. The fixtures below pin both halves of each contract.
tests:
- it: omits _namespace.gateway when _cluster.gateway-enabled is missing (default)
asserts:
@@ -102,7 +103,7 @@ tests:
path: stringData["values.yaml"]
pattern: '(?m)^\s+seaweedfs: tenant-root$'
- it: keeps _namespace.{etcd,ingress,monitoring,seaweedfs} unconditional when Gateway is off — regression guard for a refactor that accidentally gates them on the same flag
- it: keeps _namespace.{etcd,ingress,monitoring} when Gateway is off — regression guard for a refactor that accidentally gates them on the same flag
asserts:
- matchRegex:
path: stringData["values.yaml"]
@@ -113,11 +114,8 @@ tests:
- matchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s+monitoring: tenant-root$'
- matchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s+seaweedfs: tenant-root$'
- it: keeps _namespace.{etcd,ingress,monitoring,seaweedfs} unconditional when Gateway is on — same guard, opposite mode
- it: keeps _namespace.{etcd,ingress,monitoring} when Gateway is on — same guard, opposite mode
set:
_cluster:
gateway-enabled: "true"
@@ -131,6 +129,9 @@ tests:
- matchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s+monitoring: tenant-root$'
- it: emits _namespace.seaweedfs=tenant-root when _cluster.seaweedfs-enabled is missing
asserts:
- matchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s+seaweedfs: tenant-root$'
@@ -143,3 +144,51 @@ tests:
- notMatchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s+ingress:'
- it: emits _namespace.seaweedfs=tenant-root when _cluster.seaweedfs-enabled is "true"
set:
_cluster:
seaweedfs-enabled: "true"
asserts:
- matchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s+seaweedfs: tenant-root$'
- it: omits _namespace.seaweedfs when _cluster.seaweedfs-enabled is "false"
set:
_cluster:
seaweedfs-enabled: "false"
asserts:
- notMatchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s+seaweedfs:'
- matchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s+monitoring: tenant-root$'
- it: omits _namespace.seaweedfs when _cluster.seaweedfs-enabled is a bool false
set:
_cluster:
seaweedfs-enabled: false
asserts:
- notMatchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s+seaweedfs:'
- it: omits _namespace.seaweedfs when _cluster.seaweedfs-enabled is null
set:
_cluster:
seaweedfs-enabled: null
asserts:
- notMatchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s+seaweedfs:'
- it: omits _namespace.seaweedfs when _cluster.seaweedfs-enabled is neither missing nor true
set:
_cluster:
seaweedfs-enabled: "no"
asserts:
- notMatchRegex:
path: stringData["values.yaml"]
pattern: '(?m)^\s+seaweedfs:'