Skip to content

Commit 5a6460d

Browse files
committed
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. Assisted-by: LLM Signed-off-by: Yan Bondarenko <[email protected]>
1 parent 55aad6f commit 5a6460d

12 files changed

Lines changed: 142 additions & 10 deletions

File tree

‎packages/apps/bucket/templates/bucketclaim.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{{- $seaweedfs := .Values._namespace.seaweedfs }}
2+
{{- if not $seaweedfs }}
3+
{{- fail "a bucket needs S3, and neither this tenant nor a tenant above it runs SeaweedFS" }}
4+
{{- end }}
25
{{- $pool := .Values.storagePool }}
36
apiVersion: objectstorage.k8s.io/v1alpha1
47
kind: BucketClaim
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
suite: bucket needs an S3 backend in its tenant chain
2+
templates:
3+
- templates/bucketclaim.yaml
4+
5+
release:
6+
name: my-bucket
7+
namespace: tenant-demo
8+
9+
tests:
10+
- it: claims the bucket class of the nearest tenant with SeaweedFS
11+
set:
12+
_namespace:
13+
seaweedfs: tenant-root
14+
asserts:
15+
- equal:
16+
path: spec.bucketClassName
17+
value: tenant-root
18+
19+
- it: refuses to render when no tenant up the chain runs SeaweedFS
20+
set:
21+
_namespace:
22+
seaweedfs: ""
23+
asserts:
24+
- failedTemplate:
25+
errorPattern: "a bucket needs S3, and neither this tenant nor a tenant above it runs SeaweedFS"

‎packages/apps/harbor/templates/bucket.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{{- $seaweedfs := .Values._namespace.seaweedfs }}
2+
{{- if not $seaweedfs }}
3+
{{- fail "harbor keeps images in S3, and neither this tenant nor a tenant above it runs SeaweedFS" }}
4+
{{- end }}
25
apiVersion: objectstorage.k8s.io/v1alpha1
36
kind: BucketClaim
47
metadata:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
suite: harbor needs an S3 backend in its tenant chain
2+
templates:
3+
- templates/bucket.yaml
4+
5+
release:
6+
name: harbor
7+
namespace: tenant-demo
8+
9+
tests:
10+
- it: claims the registry bucket from the nearest tenant with SeaweedFS
11+
set:
12+
_namespace:
13+
seaweedfs: tenant-root
14+
asserts:
15+
- equal:
16+
path: spec.bucketClassName
17+
value: tenant-root
18+
documentIndex: 0
19+
20+
- it: refuses to render when no tenant up the chain runs SeaweedFS
21+
set:
22+
_namespace:
23+
seaweedfs: ""
24+
asserts:
25+
- failedTemplate:
26+
errorPattern: "harbor keeps images in S3, and neither this tenant nor a tenant above it runs SeaweedFS"

‎packages/core/platform/templates/apps.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ stringData:
253253
null/omitted in custom values. Missing key -> the true default,
254254
matching the chart values.yaml. */}}
255255
monitoring-enabled: {{ dig "rootEnabled" true (.Values.monitoring | default dict) | quote }}
256+
seaweedfs-enabled: {{ dig "rootEnabled" true (.Values.seaweedfs | default dict) | quote }}
256257
{{- /* The rate each shared-central tracing tenant's collector holds it
257258
to. Only written when set: every release in every tenant reads
258259
this Secret, and a key appearing would upgrade all of them. */}}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
suite: apps.yaml wires seaweedfs.rootEnabled into _cluster
2+
templates:
3+
- templates/apps.yaml
4+
5+
release:
6+
name: cozy-platform
7+
namespace: cozy-system
8+
9+
tests:
10+
- it: writes seaweedfs-enabled true by default
11+
asserts:
12+
- matchRegex:
13+
path: stringData["values.yaml"]
14+
pattern: '(?m)^\s*seaweedfs-enabled:\s*"true"'
15+
16+
- it: writes seaweedfs-enabled false when seaweedfs.rootEnabled is disabled
17+
set:
18+
seaweedfs.rootEnabled: false
19+
asserts:
20+
- matchRegex:
21+
path: stringData["values.yaml"]
22+
pattern: '(?m)^\s*seaweedfs-enabled:\s*"false"'
23+
24+
- it: falls back to true (no panic) when seaweedfs is null
25+
set:
26+
seaweedfs: null
27+
asserts:
28+
- matchRegex:
29+
path: stringData["values.yaml"]
30+
pattern: '(?m)^\s*seaweedfs-enabled:\s*"true"'

‎packages/core/platform/values-isp-hosted-slim.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ bundles:
2626
# into it would dead-end; see monitoring.rootEnabled in values.yaml.
2727
monitoring:
2828
rootEnabled: false
29+
# Tenant/root does not run SeaweedFS here either, so tenants must not take it
30+
# as their S3. See seaweedfs.rootEnabled in values.yaml.
31+
seaweedfs:
32+
rootEnabled: false

‎packages/core/platform/values-isp-slim-generic.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ bundles:
3131
# into it would dead-end; see monitoring.rootEnabled in values.yaml.
3232
monitoring:
3333
rootEnabled: false
34+
# Tenant/root does not run SeaweedFS here either, so tenants must not take it
35+
# as their S3. See seaweedfs.rootEnabled in values.yaml.
36+
seaweedfs:
37+
rootEnabled: false

‎packages/core/platform/values-isp-slim.yaml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ bundles:
3131
# into it would dead-end; see monitoring.rootEnabled in values.yaml.
3232
monitoring:
3333
rootEnabled: false
34+
# Tenant/root does not run SeaweedFS here either, so tenants must not take it
35+
# as their S3. See seaweedfs.rootEnabled in values.yaml.
36+
seaweedfs:
37+
rootEnabled: false

‎packages/core/platform/values.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,13 @@ gateway:
669669
- cozy-monitoring
670670
- cozy-linstor-gui
671671
- default
672+
# Platform object storage configuration.
673+
seaweedfs:
674+
# Whether the root tenant (tenant-root) runs SeaweedFS, i.e. Tenant/root
675+
# spec.seaweedfs=true. Tenants without their own SeaweedFS take tenant-root
676+
# as their S3 only when this is true. Keep it in sync with Tenant/root
677+
# spec.seaweedfs, the default true preserves the historical behaviour.
678+
rootEnabled: true
672679
# Platform monitoring configuration.
673680
monitoring:
674681
# Whether the root tenant (tenant-root) hosts the platform

0 commit comments

Comments
 (0)