fix(helm): make the data-files claim access modes configurable (#4425)

main
Jay0130-a 2026-10-17 23:16:52 +08:00 committed by GitHub
parent a9290dcb60
commit 0aa1a517c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 38 additions and 2 deletions

View File

@ -73,7 +73,7 @@ metadata:
{{- include "weknora.componentLabels" (dict "component" "storage" "context" .) | nindent 4 }}
spec:
accessModes:
- ReadWriteOnce
{{- toYaml (.Values.dataFiles.persistence.accessModes | default (list "ReadWriteOnce")) | nindent 4 }}
resources:
requests:
storage: {{ .Values.dataFiles.persistence.size }}

View File

@ -101,6 +101,32 @@ class AppStorageTests(unittest.TestCase):
env = app["spec"]["template"]["spec"]["containers"][0]["env"]
self.assertIn({"name": "STORAGE_TYPE", "value": "local"}, env)
def data_files_claim(self, documents):
return next(doc for doc in documents
if doc["kind"] == "PersistentVolumeClaim"
and doc["metadata"]["name"] == "audit-weknora-data-files")
def test_data_files_claim_defaults_to_read_write_once(self):
pvc = self.data_files_claim(self.documents())
self.assertEqual(pvc["spec"]["accessModes"], ["ReadWriteOnce"])
def test_data_files_access_modes_are_configurable(self):
"""A shared filesystem can keep the chart's rolling-update default.
The claim was hard-coded to ReadWriteOnce, so an RWX storage class
could not be used for the chart-created volume at all: the upgrade
then failed with Multi-Attach and the only way out was an
``existingClaim``. Setting the access modes lets that deployment keep
``app.strategy.type: RollingUpdate``.
"""
documents = self.documents({"dataFiles": {"persistence": {
"accessModes": ["ReadWriteMany"],
}}})
self.assertEqual(self.data_files_claim(documents)["spec"]["accessModes"],
["ReadWriteMany"])
app = self.app(documents)
self.assertEqual(app["spec"]["strategy"]["type"], "RollingUpdate")
def test_shared_storage_example_references_existing_claim(self):
values = self.readme_values("values-production.yaml")
override = self.readme_values("values-shared-storage.yaml")

View File

@ -62,7 +62,11 @@ app:
# -- Number of replicas
replicaCount: 1
# -- App update strategy. Use Recreate for single-replica, single-node-attach storage.
# -- App update strategy. `RollingUpdate` needs storage that can be attached
# by two Pods at once: with the default `ReadWriteOnce` `data-files` claim an
# upgrade fails with `Multi-Attach error` unless this is `Recreate`. Set
# `dataFiles.persistence.accessModes` to `ReadWriteMany` to keep rolling
# updates with more than one replica.
strategy:
type: RollingUpdate
# -- Only used with RollingUpdate; integers and percentages are supported.
@ -366,6 +370,12 @@ dataFiles:
enabled: true
# -- Size of the PVC
size: 10Gi
# -- Access modes for the created `data-files` claim. The chart's default
# single-writer claim requires `app.strategy.type: Recreate` (see
# `app.strategy`); set `ReadWriteMany` here when the storage class supports
# it (NFS, CephFS, EFS, ...) and the App can keep rolling updates.
accessModes:
- ReadWriteOnce
# -- Use existing PVC (leave empty to create new)
existingClaim: ""