Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix(helm): derive safe app rollout strategy for RWO storage (#4756)
杰尼龟093ddd87184f
diff --git a/helm/README.md b/helm/README.mdindex 597b05db7..4fdc9b404 100644--- a/helm/README.md+++ b/helm/README.md@@ -146,11 +146,10 @@ helm install weknora ./helm \The chart-created data-files PVC uses `ReadWriteOnce` (RWO). RWO allows severalPods to mount the volume on the same node; it does not provide shared writable-access across nodes. With a single-node-attach volume, the default rolling update-(`maxSurge: 1`, `maxUnavailable: 0`) can leave a replacement Pod waiting for the-old Pod's attachment to be released. `Recreate` terminates the old Pods before-starting replacements during an upgrade, so **App upgrades have downtime**;-volume detach/attach can still take time. This strategy does not make RWO storage+access across nodes. When `app.strategy.type` is omitted, the chart detects this+single-writer storage and defaults to `Recreate`, which terminates the old Pods+before starting replacements. **App upgrades have downtime**; volume+detach/attach can still take time. This strategy does not make RWO storagesuitable for multiple App replicas across nodes. See Kubernetes documentation on[access modes](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#access-modes)and [Deployment strategies](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy).@@ -252,7 +251,7 @@ pre-existing Service name does not automatically transfer its ownership to Helm.|-----------|-------------|---------|| `app.enabled` | Enable backend | `true` || `app.replicaCount` | Number of replicas | `1` |-| `app.strategy.type` | App update strategy: `RollingUpdate` or `Recreate` | `RollingUpdate` |+| `app.strategy.type` | App update strategy: `RollingUpdate` or `Recreate`; empty selects `Recreate` for persistent non-RWX data-files storage and `RollingUpdate` otherwise | `""` || `app.strategy.rollingUpdate.maxSurge` | Extra Pods during rolling updates (integer or percentage); ignored with `Recreate` | `1` || `app.strategy.rollingUpdate.maxUnavailable` | Unavailable Pods during rolling updates (integer or percentage); ignored with `Recreate` | `0` || `app.image.repository` | Image repository | `wechatopenai/weknora-app` |@@ -261,6 +260,14 @@ pre-existing Service name does not automatically transfer its ownership to Helm.| `app.env` | Environment variables | See values.yaml || `app.extraEnv` | Additional env vars | `[]` |+### Data Files Storage++| Parameter | Description | Default |+|-----------|-------------|---------|+| `dataFiles.persistence.enabled` | Create or mount persistent uploaded-file storage | `true` |+| `dataFiles.persistence.accessModes` | Access modes for a chart-created data-files PVC; `ReadWriteMany` permits rolling App updates | `[ReadWriteOnce]` |+| `dataFiles.persistence.existingClaim` | Use a pre-provisioned PVC instead of creating one | `""` |+### Frontend| Parameter | Description | Default |diff --git a/helm/templates/app.yaml b/helm/templates/app.yamlindex 1767aec8e..07db06c8b 100644--- a/helm/templates/app.yaml+++ b/helm/templates/app.yaml@@ -19,7 +19,12 @@ spec:{{- include "weknora.componentSelectorLabels" (dict "component" "app" "context" .) | nindent 6 }}strategy:{{- $strategy := .Values.app.strategy | default dict }}- {{- $strategyType := $strategy.type | default "RollingUpdate" }}+ {{- $accessModes := .Values.dataFiles.persistence.accessModes | default (list "ReadWriteOnce") }}+ {{- $defaultStrategyType := "RollingUpdate" }}+ {{- if and .Values.dataFiles.persistence.enabled (not (has "ReadWriteMany" $accessModes)) }}+ {{- $defaultStrategyType = "Recreate" }}+ {{- end }}+ {{- $strategyType := $strategy.type | default $defaultStrategyType }}{{- if not (has $strategyType (list "RollingUpdate" "Recreate")) }}{{- fail "app.strategy.type must be RollingUpdate or Recreate" }}{{- end }}diff --git a/helm/tests/test_app_storage.py b/helm/tests/test_app_storage.pyindex 3939dfd5c..0cce00bed 100644--- a/helm/tests/test_app_storage.py+++ b/helm/tests/test_app_storage.py@@ -56,8 +56,29 @@ class AppStorageTests(unittest.TestCase):return yaml.safe_load(next(block for block in blocksif block.startswith(f"# {filename}\n")))- def test_default_strategy_is_unchanged(self):+ def test_persistent_single_writer_storage_defaults_to_recreate(self):app = self.app(self.documents())+ self.assertEqual(app["spec"]["strategy"], {+ "type": "Recreate",+ })++ def test_nonpersistent_storage_defaults_to_rolling_update(self):+ app = self.app(self.documents({"dataFiles": {"persistence": {"enabled": False}}}))+ self.assertEqual(app["spec"]["strategy"], {+ "type": "RollingUpdate",+ "rollingUpdate": {"maxSurge": 1, "maxUnavailable": 0},+ })++ def test_shared_storage_defaults_to_rolling_update(self):+ app = self.app(self.documents({"dataFiles": {"persistence": {+ "accessModes": ["ReadWriteMany"],+ }}}))+ self.assertEqual(app["spec"]["strategy"]["type"], "RollingUpdate")++ def test_explicit_rolling_update_overrides_safe_default(self):+ app = self.app(self.documents({"app": {"strategy": {+ "type": "RollingUpdate",+ }}}))self.assertEqual(app["spec"]["strategy"], {"type": "RollingUpdate","rollingUpdate": {"maxSurge": 1, "maxUnavailable": 0},@@ -78,10 +99,7 @@ class AppStorageTests(unittest.TestCase):def test_null_strategy_falls_back_to_defaults(self):app = self.app(self.documents({"app": {"strategy": None}}))- self.assertEqual(app["spec"]["strategy"], {- "type": "RollingUpdate",- "rollingUpdate": {"maxSurge": 1, "maxUnavailable": 0},- })+ self.assertEqual(app["spec"]["strategy"], {"type": "Recreate"})def test_invalid_strategy_is_rejected(self):result = render({"app": {"strategy": {"type": "Invalid"}}})diff --git a/helm/values.yaml b/helm/values.yamlindex bc44dec4f..a4cf1e619 100644--- a/helm/values.yaml+++ b/helm/values.yaml@@ -62,13 +62,12 @@ app:# -- Number of replicasreplicaCount: 1- # -- 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.+ # -- App update strategy. Leave empty to select a safe default from the+ # data-files storage: `Recreate` for a persistent single-writer claim, and+ # `RollingUpdate` when persistence is disabled or `ReadWriteMany` is used.+ # Set this explicitly to override the derived strategy.strategy:- type: RollingUpdate+ type: ""# -- Only used with RollingUpdate; integers and percentages are supported.rollingUpdate:maxSurge: 1