mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
fix(seaweedfs): reserve the -public suffix in pool names
A pool's classes take its name as a prefix, so a pool named <x>-public renders a readwrite BucketAccessClass <ns>-<x>-public with the same name as pool <x>'s public-read class, and whichever object wins gives one of the two pools the wrong policy. A pool named public takes <ns>-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 <mattia@hidora.io>
This commit is contained in:
2 files changed
+67
-4
No files matched your search
@@ -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) }}
|
||||
|
||||
@@ -48,3 +48,66 @@ tests:
|
||||
- equal:
|
||||
path: parameters.accessPolicy
|
||||
value: public-read
|
||||
|
||||
# A pool named <x>-public would render a readwrite BucketAccessClass
|
||||
# <ns>-<x>-public, the same name as pool <x>'s public-read class; a pool named
|
||||
# public would take <ns>-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: {}
|
||||
Reference in new issue
Block a user