From ced338f4f1b9b2700baa6069c5aa28870b657b54 Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Fri, 27 Nov 2026 01:30:49 +0100 Subject: [PATCH] fix(linstor): pause the satellite rollout until the first adjust The blockstor-satellite DaemonSet took the Kubernetes default update strategy. The satellite reports Ready once its caches have synced, seconds after start, while re-rendering and adjusting every DRBD resource on the node takes minutes: on a test cluster a satellite finished about 110 resources 1.5 to 2.7 minutes after it turned Ready. An image bump therefore rolled every node seconds apart. Hold each node for minReadySeconds, 180 by default, after Ready, one node at a time, and let an operator choose OnDelete to check every node by hand. maxUnavailable takes only 1 or 0 and a surge is refused, because two satellites on one node would both drive its DRBD resources and a wider rollout runs several first passes at once. Readiness never drops after the cache sync, so the pause stops only a satellite that exits or restarts; OnDelete with the per-node checks is the gate for a change in how resources render. The README describes the node-by-node upgrade, what waits for the rollout (the linstor HelmRelease past the upgrade timeout and HelmReleaseNotReady, and the dependent scheduler and gui releases), and that rolling back means reverting the change that brought the version. Assisted-by: LLM Signed-off-by: Andrei Kvapil --- packages/system/linstor/README.md | 21 +++ .../templates/blockstor-satellite.yaml | 42 ++++++ .../tests/blockstor_workloads_test.yaml | 135 ++++++++++++++++++ packages/system/linstor/values.yaml | 24 ++++ 4 files changed, 222 insertions(+) diff --git a/packages/system/linstor/README.md b/packages/system/linstor/README.md index ab5e4f1aa..8f6785bb9 100644 --- a/packages/system/linstor/README.md +++ b/packages/system/linstor/README.md @@ -25,3 +25,24 @@ Drain workloads before a planned node shutdown. The hook has a 60-second work bu Related upstream discussion: [Piraeus orderly shutdown on Talos](https://github.com/piraeusdatastore/piraeus-operator/issues/860). Run `make test` in this directory with Helm, helm-unittest and Python 3.11 or later. The tests cover rendering with each feature flag, resource selection and rechecks, bounded errors and timeouts, dry-run behavior, and logging in the shared pod PID namespace. + +## Upgrading the blockstor satellites + +The `blockstor-satellite` DaemonSet replaces its pods one node at a time and holds the rollout on each node for `blockstorSatellite.minReadySeconds` (180 by default) after the new pod turns Ready. Ready only means the satellite's caches have synced, which takes seconds; its first pass, which re-renders and adjusts every DRBD resource on the node, ended 1.5 to 2.7 minutes after Ready on a test cluster with about 110 resources per node. The default covers that, so first passes on two nodes do not overlap; a node with more resources needs a longer pause. `maxUnavailable` is always 1 and `maxSurge` always 0, and the chart refuses other values: a wider rollout would run several first passes at once, and a second satellite on the node would drive the same DRBD resources. + +The pause stops the rollout only if the satellite exits or restarts within it. Readiness does not drop when resources fail to adjust: a satellite that renders a bad `.res`, or whose `drbdadm adjust` fails, keeps running and stays Ready, and the next node follows once the pause is over. For an upgrade that changes how the satellite renders DRBD resources, the per-node procedure below is the only check that catches that. + +The `linstor` HelmRelease waits for the whole rollout, and every node adds its pause to it: about 3.5 minutes per node at the default. cozystack-operator gives a package upgrade 10 minutes (`--helmrelease-upgrade-timeout`), which covers two nodes with room and three only just. On a larger cluster the first upgrade attempt times out while the DaemonSet keeps rolling; the release retries the upgrade, becomes Ready once the last node is done, and runs its post-upgrade hooks with the attempt that succeeds. Lower `minReadySeconds`, or raise the operator's timeout, if that is not acceptable. Changing either value does not restart the satellites. While the rollout runs: + +- the HelmRelease is not Ready, and `HelmReleaseNotReady` fires once that has lasted 5 minutes, so on a satellite image change for any cluster of two nodes or more; +- `cozystack.linstor-scheduler` and `cozystack.linstor-gui` depend on `cozystack.linstor`, and their own upgrades wait for it. + +For an upgrade that changes how the satellite renders DRBD resources, check each node before the next one goes. Set `blockstorSatellite.updateStrategy.type: OnDelete` in `spec.components.linstor.values` of the `cozystack.linstor` Package before the upgrade, so that nothing moves until a pod is deleted. Run every command below in the `satellite` container of that node's pod, `kubectl -n cozy-linstor exec -c satellite -- `: it holds the rendered `/etc/drbd.d`, and `drbdadm` on the host or in another container reads a different configuration. + +1. Before the upgrade, save `drbdsetup show` and `drbdsetup status --verbose` from every node. +2. Upgrade. The controller and the apiserver roll; the satellites stay on the old version. +3. Delete the satellite pod on one node and wait for the new one to be Ready and for its first pass to finish. Nothing reports the end of the pass yet. Every `.res` file whose rendering the release changes gets a new modification time in `/etc/drbd.d` (`ls -l --time-style=full-iso /etc/drbd.d`), and step 4 shows whether anything is still pending; wait at least 3 minutes after Ready on a node with about a hundred resources. +4. On that node, `drbdadm -d adjust all` prints nothing, `drbdsetup show` differs from the saved copy only where the release notes say it does, and `drbdsetup status` shows every resource in the role, disk and connection state it had before, none of them suspended. If `drbdadm -d adjust all` still prints something, the pass has not finished or has failed: wait and run it again, and read the satellite's log before going on. +5. Repeat steps 3 and 4 for the next node, then set the strategy back to `RollingUpdate`. + +Under `OnDelete` the HelmRelease cannot become Ready until every satellite has been replaced by hand: the upgrade attempt times out and retries, as above, and everything listed above lasts until the last pod, which may be hours. To roll back, first revert the change that brought the new version, the platform version or the `cozystack.linstor` Package values, rather than running `helm rollback`, which helm-controller undoes; then replace the satellites one node at a time the same way. diff --git a/packages/system/linstor/templates/blockstor-satellite.yaml b/packages/system/linstor/templates/blockstor-satellite.yaml index 2e2f07503..d92b61362 100644 --- a/packages/system/linstor/templates/blockstor-satellite.yaml +++ b/packages/system/linstor/templates/blockstor-satellite.yaml @@ -157,6 +157,48 @@ metadata: app.kubernetes.io/component: blockstor-satellite spec: selector: {matchLabels: {app: blockstor-satellite}} + {{- /* + Without these the DaemonSet takes the Kubernetes default, which moves + to the next node as soon as the new pod is Ready: seconds after start, + long before the satellite has adjusted the node's DRBD resources. + The pause stops the rollout only if the satellite exits or restarts + within it: readiness never drops on an adjust error, so a satellite + that keeps running with failed resources does not stop it. + One node at a time and no surge are not values: a wider rollout runs + several first passes at once, a surge pod would run a second + satellite against the same host DRBD state, and maxUnavailable 0 + with maxSurge 0 is refused by the apiserver. */}} + {{- $strategy := .Values.blockstorSatellite.updateStrategy | default dict }} + {{- $minReady := .Values.blockstorSatellite.minReadySeconds }} + {{- $minReadyErr := printf "linstor: blockstorSatellite.minReadySeconds must be a whole number of seconds, 0 or more, got %s" (toJson $minReady) }} + {{- if not (or (kindIs "float64" $minReady) (kindIs "int64" $minReady) (kindIs "int" $minReady)) }} + {{- fail $minReadyErr }} + {{- end }} + {{- if or (lt (float64 $minReady) 0.0) (ne (float64 $minReady) (float64 (int64 $minReady))) }} + {{- fail $minReadyErr }} + {{- end }} + minReadySeconds: {{ int64 $minReady }} + updateStrategy: + {{- if eq (toString $strategy.type) "RollingUpdate" }} + {{- $rolling := $strategy.rollingUpdate | default dict }} + {{- if not (kindIs "map" $rolling) }} + {{- fail (printf "linstor: blockstorSatellite.updateStrategy.rollingUpdate must be a map, got %s" (toJson $rolling)) }} + {{- end }} + {{- if and (hasKey $rolling "maxUnavailable") (ne (toJson $rolling.maxUnavailable) "1") }} + {{- fail (printf "linstor: blockstorSatellite.updateStrategy.rollingUpdate.maxUnavailable can only be 1, got %s" (toJson $rolling.maxUnavailable)) }} + {{- end }} + {{- if and (hasKey $rolling "maxSurge") (ne (toJson $rolling.maxSurge) "0") }} + {{- fail (printf "linstor: blockstorSatellite.updateStrategy.rollingUpdate.maxSurge can only be 0, got %s" (toJson $rolling.maxSurge)) }} + {{- end }} + type: RollingUpdate + rollingUpdate: + maxUnavailable: 1 + maxSurge: 0 + {{- else if eq (toString $strategy.type) "OnDelete" }} + type: OnDelete + {{- else }} + {{- fail (printf "linstor: blockstorSatellite.updateStrategy.type must be \"RollingUpdate\" or \"OnDelete\", got %q" (toString $strategy.type)) }} + {{- end }} template: metadata: labels: diff --git a/packages/system/linstor/tests/blockstor_workloads_test.yaml b/packages/system/linstor/tests/blockstor_workloads_test.yaml index c4dafa2ba..50b11cd4d 100644 --- a/packages/system/linstor/tests/blockstor_workloads_test.yaml +++ b/packages/system/linstor/tests/blockstor_workloads_test.yaml @@ -341,6 +341,141 @@ tests: path: spec.template.metadata.annotations["checksum/drbd-conf"] pattern: '^[0-9a-f]{64}$' + # The satellite is Ready once its caches sync, minutes before its first + # adjust pass is done; the Kubernetes default would move to the next node + # right then. The pause covers the pass measured on a test cluster, up + # to 160s after Ready for about 110 resources. + - it: rolls the satellites one node at a time with a pause after Ready + template: templates/blockstor-satellite.yaml + documentSelector: + path: kind + value: DaemonSet + asserts: + - equal: + path: spec.minReadySeconds + value: 180 + - equal: + path: spec.updateStrategy + value: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 1 + maxSurge: 0 + + # Two satellites on one node would both drive its DRBD resources. + - it: never surges a second satellite onto a node + template: templates/blockstor-satellite.yaml + documentSelector: + path: kind + value: DaemonSet + set: + blockstorSatellite: + minReadySeconds: 0 + updateStrategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 1 + maxSurge: 0 + asserts: + - equal: + path: spec.minReadySeconds + value: 0 + - equal: + path: spec.updateStrategy.rollingUpdate + value: + maxUnavailable: 1 + maxSurge: 0 + + - it: refuses a surge pod + template: templates/blockstor-satellite.yaml + set: + blockstorSatellite.updateStrategy.rollingUpdate.maxSurge: 1 + asserts: + - failedTemplate: + errorMessage: 'linstor: blockstorSatellite.updateStrategy.rollingUpdate.maxSurge can only be 0, got 1' + + # Several nodes at once run their first adjust passes together. + - it: refuses a rollout wider than one node + template: templates/blockstor-satellite.yaml + set: + blockstorSatellite.updateStrategy.rollingUpdate.maxUnavailable: 5 + asserts: + - failedTemplate: + errorMessage: 'linstor: blockstorSatellite.updateStrategy.rollingUpdate.maxUnavailable can only be 1, got 5' + + - it: refuses a percentage rollout + template: templates/blockstor-satellite.yaml + set: + blockstorSatellite.updateStrategy.rollingUpdate.maxUnavailable: 50% + asserts: + - failedTemplate: + errorMessage: 'linstor: blockstorSatellite.updateStrategy.rollingUpdate.maxUnavailable can only be 1, got "50%"' + + # With maxSurge 0 the apiserver refuses it, after the chart's own checks. + - it: refuses a rollout that replaces no node + template: templates/blockstor-satellite.yaml + set: + blockstorSatellite.updateStrategy.rollingUpdate.maxUnavailable: 0 + asserts: + - failedTemplate: + errorMessage: 'linstor: blockstorSatellite.updateStrategy.rollingUpdate.maxUnavailable can only be 1, got 0' + + # OnDelete alone: the API keeps a rollingUpdate block it would ignore. + - it: replaces a satellite only when its pod is deleted under OnDelete + template: templates/blockstor-satellite.yaml + documentSelector: + path: kind + value: DaemonSet + set: + blockstorSatellite.updateStrategy.type: OnDelete + asserts: + - equal: + path: spec.updateStrategy + value: + type: OnDelete + + - it: refuses an update strategy the DaemonSet does not have + template: templates/blockstor-satellite.yaml + set: + blockstorSatellite.updateStrategy.type: Recreate + asserts: + - failedTemplate: + errorMessage: 'linstor: blockstorSatellite.updateStrategy.type must be "RollingUpdate" or "OnDelete", got "Recreate"' + + - it: refuses a negative minReadySeconds + template: templates/blockstor-satellite.yaml + set: + blockstorSatellite.minReadySeconds: -1 + asserts: + - failedTemplate: + errorMessage: 'linstor: blockstorSatellite.minReadySeconds must be a whole number of seconds, 0 or more, got -1' + + - it: refuses a minReadySeconds that is not a number + template: templates/blockstor-satellite.yaml + set: + blockstorSatellite.minReadySeconds: 2m + asserts: + - failedTemplate: + errorMessage: 'linstor: blockstorSatellite.minReadySeconds must be a whole number of seconds, 0 or more, got "2m"' + + # --set hands a decimal over as a string; the message must still say + # what is wrong with it. + - it: refuses a decimal minReadySeconds given as a string + template: templates/blockstor-satellite.yaml + set: + blockstorSatellite.minReadySeconds: "1.5" + asserts: + - failedTemplate: + errorMessage: 'linstor: blockstorSatellite.minReadySeconds must be a whole number of seconds, 0 or more, got "1.5"' + + - it: refuses a decimal minReadySeconds + template: templates/blockstor-satellite.yaml + set: + blockstorSatellite.minReadySeconds: 1.5 + asserts: + - failedTemplate: + errorMessage: 'linstor: blockstorSatellite.minReadySeconds must be a whole number of seconds, 0 or more, got 1.5' + # A SIGTERM must not cut a detached rollback short: the pod outlives the # REST server's shutdown window. - it: gives the controller time to finish a rollback on shutdown diff --git a/packages/system/linstor/values.yaml b/packages/system/linstor/values.yaml index 527fdfd73..e85eac749 100644 --- a/packages/system/linstor/values.yaml +++ b/packages/system/linstor/values.yaml @@ -36,6 +36,30 @@ blockstorSatellite: image: repository: ghcr.io/cozystack/blockstor-satellite tag: 0.3.0@sha256:abff381da5425fdf7a6abc0d52006727cf7fe13c438acc79aaea192fc8681cb4 + # How a change to the satellite pod template reaches the nodes. The + # satellite turns Ready once its caches have synced, seconds after + # start; its first pass over the node's DRBD resources ends later and + # does not show in readiness. minReadySeconds holds the rollout on each + # node for that long after Ready, so that first passes on two nodes do + # not overlap. 180 covers the passes measured on a test cluster, 1.5 to + # 2.7 minutes after Ready for about 110 resources per node; a node with + # more resources needs longer. + # The pause stops the rollout only if the satellite exits or restarts + # within it. A satellite that keeps running while resources fail to + # adjust stays Ready, and the next node follows. For an upgrade that + # changes how resources are rendered, use OnDelete and the per-node + # checks in "Upgrading the blockstor satellites" in README.md. + # Every node adds the pause to the rollout, and the HelmRelease upgrade + # waits for the whole rollout: see the same section before raising it. + minReadySeconds: 180 + updateStrategy: + # RollingUpdate replaces one node at a time; OnDelete replaces a pod + # only when it is deleted, for an upgrade checked node by node. + # rollingUpdate may be left out: maxUnavailable can only be 1, since + # several nodes would run their first passes at once, and maxSurge + # only 0, since two satellites on one node would both drive its DRBD + # resources. The chart refuses other values. + type: RollingUpdate # The Secret, in this namespace, whose MASTER_PASSPHRASE key unlocks the # blockstor master key that wraps every LUKS volume password. It is the # Secret piraeus reads for LINSTOR, so a cluster migrated from LINSTOR keeps