Skip to content

Commit fa1cf77

Browse files
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 <[email protected]>
1 parent c2d370e commit fa1cf77

2 files changed

Lines changed: 67 additions & 4 deletions

File tree

‎packages/extra/seaweedfs/templates/seaweedfs.yaml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
{{- if not (regexMatch "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$" $poolName) }}
3333
{{- fail (printf "volume.pools key '%s' must be a valid DNS label (lowercase alphanumeric and hyphens, no dots)." $poolName) }}
3434
{{- end }}
35-
{{- if or (hasSuffix "-lock" $poolName) (hasSuffix "-readonly" $poolName) }}
36-
{{- fail (printf "volume.pools key '%s' must not end with '-lock' or '-readonly' (reserved suffixes for COSI resources)." $poolName) }}
35+
{{- if or (hasSuffix "-lock" $poolName) (hasSuffix "-readonly" $poolName) (hasSuffix "-public" $poolName) (eq "public" $poolName) }}
36+
{{- fail (printf "volume.pools key '%s' must not be 'public' or end with '-lock', '-readonly' or '-public' (reserved for COSI resources)." $poolName) }}
3737
{{- end }}
3838
{{- if not $pool.diskType }}
3939
{{- fail (printf "volume.pools.%s.diskType is required." $poolName) }}
@@ -52,8 +52,8 @@
5252
{{- if not (regexMatch "^[a-z0-9]([a-z0-9-]*[a-z0-9])?$" $poolName) }}
5353
{{- fail (printf "volume.zones.%s.pools key '%s' must be a valid DNS label." $zoneName $poolName) }}
5454
{{- end }}
55-
{{- if or (hasSuffix "-lock" $poolName) (hasSuffix "-readonly" $poolName) }}
56-
{{- fail (printf "volume.zones.%s.pools key '%s' must not end with '-lock' or '-readonly' (reserved suffixes for COSI resources)." $zoneName $poolName) }}
55+
{{- if or (hasSuffix "-lock" $poolName) (hasSuffix "-readonly" $poolName) (hasSuffix "-public" $poolName) (eq "public" $poolName) }}
56+
{{- 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) }}
5757
{{- end }}
5858
{{- if not $pool.diskType }}
5959
{{- fail (printf "volume.zones.%s.pools.%s.diskType is required." $zoneName $poolName) }}

‎packages/extra/seaweedfs/tests/public_access_class_test.yaml‎

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,66 @@ tests:
4848
- equal:
4949
path: parameters.accessPolicy
5050
value: public-read
51+
52+
# A pool named <x>-public would render a readwrite BucketAccessClass
53+
# <ns>-<x>-public, the same name as pool <x>'s public-read class; a pool named
54+
# public would take <ns>-public, the instance's own public-read class.
55+
- it: refuses a pool name ending in -public
56+
template: templates/seaweedfs.yaml
57+
set:
58+
volume:
59+
pools:
60+
fast:
61+
diskType: ssd
62+
fast-public:
63+
diskType: nvme
64+
asserts:
65+
- failedTemplate:
66+
errorPattern: volume.pools key 'fast-public' must not be 'public' or end with
67+
68+
- it: refuses a pool named public
69+
template: templates/seaweedfs.yaml
70+
set:
71+
volume:
72+
pools:
73+
public:
74+
diskType: ssd
75+
asserts:
76+
- failedTemplate:
77+
errorPattern: volume.pools key 'public' must not be 'public' or end with
78+
79+
- it: refuses a zone pool name ending in -public
80+
template: templates/seaweedfs.yaml
81+
set:
82+
topology: MultiZone
83+
replicationFactor: 1
84+
volume:
85+
zones:
86+
a:
87+
pools:
88+
fast-public:
89+
diskType: ssd
90+
asserts:
91+
- failedTemplate:
92+
errorPattern: volume.zones.a.pools key 'fast-public' must not be 'public' or end with
93+
94+
- it: still refuses a pool name ending in -readonly
95+
template: templates/seaweedfs.yaml
96+
set:
97+
volume:
98+
pools:
99+
fast-readonly:
100+
diskType: ssd
101+
asserts:
102+
- failedTemplate:
103+
errorPattern: volume.pools key 'fast-readonly' must not be 'public' or end with
104+
105+
- it: accepts a pool name that only contains public
106+
template: templates/seaweedfs.yaml
107+
set:
108+
volume:
109+
pools:
110+
publicfast:
111+
diskType: ssd
112+
asserts:
113+
- notFailedTemplate: {}

0 commit comments

Comments
 (0)