From fa1cf776708758aac18f5daf5a64462a2d478b9f Mon Sep 17 00:00:00 2001 From: Mattia Eleuteri Date: Fri, 13 Nov 2026 11:04:57 +0100 Subject: [PATCH] fix(seaweedfs): reserve the -public suffix in pool names A pool's classes take its name as a prefix, so a pool named -public renders a readwrite BucketAccessClass --public with the same name as pool 's public-read class, and whichever object wins gives one of the two pools the wrong policy. A pool named public takes -public, the instance's own public-read class. The pool name check already reserves -lock and -readonly for the same reason. Assisted-by: LLM Signed-off-by: Mattia Eleuteri --- .../extra/seaweedfs/templates/seaweedfs.yaml | 8 +-- .../tests/public_access_class_test.yaml | 63 +++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/packages/extra/seaweedfs/templates/seaweedfs.yaml b/packages/extra/seaweedfs/templates/seaweedfs.yaml index 92b40ef4d..ed24b8fe4 100644 --- a/packages/extra/seaweedfs/templates/seaweedfs.yaml +++ b/packages/extra/seaweedfs/templates/seaweedfs.yaml @@ -32,8 +32,8 @@ {{- if not (regexMatch "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$" $poolName) }} {{- fail (printf "volume.pools key '%s' must be a valid DNS label (lowercase alphanumeric and hyphens, no dots)." $poolName) }} {{- end }} -{{- if or (hasSuffix "-lock" $poolName) (hasSuffix "-readonly" $poolName) }} -{{- fail (printf "volume.pools key '%s' must not end with '-lock' or '-readonly' (reserved suffixes for COSI resources)." $poolName) }} +{{- if or (hasSuffix "-lock" $poolName) (hasSuffix "-readonly" $poolName) (hasSuffix "-public" $poolName) (eq "public" $poolName) }} +{{- fail (printf "volume.pools key '%s' must not be 'public' or end with '-lock', '-readonly' or '-public' (reserved for COSI resources)." $poolName) }} {{- end }} {{- if not $pool.diskType }} {{- fail (printf "volume.pools.%s.diskType is required." $poolName) }} @@ -52,8 +52,8 @@ {{- if not (regexMatch "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$" $poolName) }} {{- fail (printf "volume.zones.%s.pools key '%s' must be a valid DNS label." $zoneName $poolName) }} {{- end }} -{{- if or (hasSuffix "-lock" $poolName) (hasSuffix "-readonly" $poolName) }} -{{- fail (printf "volume.zones.%s.pools key '%s' must not end with '-lock' or '-readonly' (reserved suffixes for COSI resources)." $zoneName $poolName) }} +{{- if or (hasSuffix "-lock" $poolName) (hasSuffix "-readonly" $poolName) (hasSuffix "-public" $poolName) (eq "public" $poolName) }} +{{- fail (printf "volume.zones.%s.pools key '%s' must not be 'public' or end with '-lock', '-readonly' or '-public' (reserved for COSI resources)." $zoneName $poolName) }} {{- end }} {{- if not $pool.diskType }} {{- fail (printf "volume.zones.%s.pools.%s.diskType is required." $zoneName $poolName) }} diff --git a/packages/extra/seaweedfs/tests/public_access_class_test.yaml b/packages/extra/seaweedfs/tests/public_access_class_test.yaml index 67ea3239c..dbbcc84e7 100644 --- a/packages/extra/seaweedfs/tests/public_access_class_test.yaml +++ b/packages/extra/seaweedfs/tests/public_access_class_test.yaml @@ -48,3 +48,66 @@ tests: - equal: path: parameters.accessPolicy value: public-read + + # A pool named -public would render a readwrite BucketAccessClass + # --public, the same name as pool 's public-read class; a pool named + # public would take -public, the instance's own public-read class. + - it: refuses a pool name ending in -public + template: templates/seaweedfs.yaml + set: + volume: + pools: + fast: + diskType: ssd + fast-public: + diskType: nvme + asserts: + - failedTemplate: + errorPattern: volume.pools key 'fast-public' must not be 'public' or end with + + - it: refuses a pool named public + template: templates/seaweedfs.yaml + set: + volume: + pools: + public: + diskType: ssd + asserts: + - failedTemplate: + errorPattern: volume.pools key 'public' must not be 'public' or end with + + - it: refuses a zone pool name ending in -public + template: templates/seaweedfs.yaml + set: + topology: MultiZone + replicationFactor: 1 + volume: + zones: + a: + pools: + fast-public: + diskType: ssd + asserts: + - failedTemplate: + errorPattern: volume.zones.a.pools key 'fast-public' must not be 'public' or end with + + - it: still refuses a pool name ending in -readonly + template: templates/seaweedfs.yaml + set: + volume: + pools: + fast-readonly: + diskType: ssd + asserts: + - failedTemplate: + errorPattern: volume.pools key 'fast-readonly' must not be 'public' or end with + + - it: accepts a pool name that only contains public + template: templates/seaweedfs.yaml + set: + volume: + pools: + publicfast: + diskType: ssd + asserts: + - notFailedTemplate: {}