From f196ef6e4a8017718d0890423db7c0f11e618bfe Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Wed, 25 Nov 2026 12:18:40 +0300 Subject: [PATCH] fix(seaweedfs): stop reserving storage pool name suffixes A storage pool named "public" or ending in "-lock", "-readonly" or "-public" was refused outright. The check that compares the class names each pool actually renders, against each other and against the instance's base classes, already refuses every one of those names that clashes with something: "public", "lock" and "readonly" clash with the base classes, and "x-public", "x-lock" or "x-readonly" clash only when a pool "x" exists. The suffix list on top of it refused names that clash with nothing, such as "cdn-public" with no pool "cdn", and had to grow, as a breaking change, with every new class variant. Drop the suffix list and keep the rendered-name check as the only rule. This accepts names that were refused before and refuses none that were accepted. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- .../extra/seaweedfs/templates/seaweedfs.yaml | 15 +-- .../tests/public_access_class_test.yaml | 119 +++++++++++------- 2 files changed, 82 insertions(+), 52 deletions(-) diff --git a/packages/extra/seaweedfs/templates/seaweedfs.yaml b/packages/extra/seaweedfs/templates/seaweedfs.yaml index 6c98591df..1a438b7c4 100644 --- a/packages/extra/seaweedfs/templates/seaweedfs.yaml +++ b/packages/extra/seaweedfs/templates/seaweedfs.yaml @@ -32,9 +32,6 @@ {{- 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) (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) }} {{- end }} @@ -52,9 +49,6 @@ {{- 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) (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) }} {{- end }} @@ -76,10 +70,11 @@ {{- end }} {{- end }} -{{- /* -lock-noretention is not a reserved suffix: releases with pools named - that way predate the class, and refusing the name would block their - upgrade. Only an actual clash between rendered class names fails, - across both pool paths and against the base classes. */ -}} +{{- /* No pool name or suffix is reserved: a reserved suffix would refuse + names that collide with nothing and block the upgrade of releases + already using them each time a class variant is added. Only an + actual clash between rendered class names fails, across both pool + paths and against the base classes. */ -}} {{- if gt (len $allPools) 0 }} {{- $classOwners := dict }} {{- range $suffix := list "" "-lock" "-lock-noretention" }} diff --git a/packages/extra/seaweedfs/tests/public_access_class_test.yaml b/packages/extra/seaweedfs/tests/public_access_class_test.yaml index dbbcc84e7..01b683957 100644 --- a/packages/extra/seaweedfs/tests/public_access_class_test.yaml +++ b/packages/extra/seaweedfs/tests/public_access_class_test.yaml @@ -49,10 +49,55 @@ tests: 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 + # Only an actual clash between rendered class names is refused, so a pool + # suffix is free to use unless another pool owns the base name. + - it: accepts a pool name ending in -public when no pool owns the base name + template: templates/storage-pool-bucket-classes.yaml + set: + topology: Simple + volume: + pools: + cdn-public: + diskType: ssd + documentSelector: + path: metadata.name + value: tenant-root-cdn-public-public + asserts: + - isKind: + of: BucketAccessClass + - equal: + path: parameters.accessPolicy + value: public-read + + - it: accepts -public, -lock and -readonly pool names without their base pool + template: templates/seaweedfs.yaml + set: + volume: + pools: + cdn-public: + diskType: ssd + cdn-lock: + diskType: hdd + cdn-readonly: + diskType: nvme + asserts: + - notFailedTemplate: {} + + - it: accepts a zone pool name ending in -public + template: templates/seaweedfs.yaml + set: + topology: MultiZone + replicationFactor: 1 + volume: + zones: + a: + pools: + cdn-public: + diskType: ssd + asserts: + - notFailedTemplate: {} + + - it: refuses a pool whose base class is another pool's -public class template: templates/seaweedfs.yaml set: volume: @@ -63,7 +108,33 @@ tests: diskType: nvme asserts: - failedTemplate: - errorPattern: volume.pools key 'fast-public' must not be 'public' or end with + errorMessage: "storage pool 'fast-public' renders BucketAccessClass tenant-root-fast-public, also rendered by storage pool 'fast'; rename the pool." + + - it: refuses a pool whose base class is another pool's -readonly class + template: templates/seaweedfs.yaml + set: + volume: + pools: + fast: + diskType: ssd + fast-readonly: + diskType: nvme + asserts: + - failedTemplate: + errorMessage: "storage pool 'fast-readonly' renders BucketAccessClass tenant-root-fast-readonly, also rendered by storage pool 'fast'; rename the pool." + + - it: refuses a pool whose base class is another pool's -lock class + template: templates/seaweedfs.yaml + set: + volume: + pools: + fast: + diskType: ssd + fast-lock: + diskType: nvme + asserts: + - failedTemplate: + errorMessage: "storage pool 'fast-lock' renders BucketClass tenant-root-fast-lock, also rendered by storage pool 'fast'; rename the pool." - it: refuses a pool named public template: templates/seaweedfs.yaml @@ -74,40 +145,4 @@ tests: 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: {} + errorMessage: "storage pool 'public' renders BucketAccessClass tenant-root-public, also rendered by the base classes; rename the pool."