mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-01 20:56:02 +09:00
feat(platform): pass the blockstor migration step to the linstor package
The cozystack.linstor Package is rendered by the platform, so a value set on it by hand is overwritten on the next reconcile. The migration step has to come from the platform values like the backend does, and is checked there so a typo or a step left over after switching back to linstor fails the platform render rather than the linstor release. linstor-scheduler and linstor-gui stay on LINSTOR until blockstorMigration is cleared, in the step that repoints linstor-csi. At hold CSI still acts on LINSTOR's state and blockstor serves nothing yet, or Resources it has not adopted, and the scheduler extender panics on a Resource without volumes, which is the shape of one before adoption. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
4 files changed
+222
-17
No files matched your search
@@ -73,7 +73,7 @@ nothing: helm template, client-side dry-run, first install.
|
||||
{{- $ack = dig "acknowledgeBackendChange" "" .Values.storage | toString -}}
|
||||
{{- end -}}
|
||||
{{- if and (ne $liveBackend $backend) (ne $ack $backend) -}}
|
||||
{{- fail (printf "the live cozystack.linstor Package runs the %q storage backend and this render would switch it to %q. The volumes this cluster already has are known only to the current backend: after the switch the CSI driver cannot attach, resize, snapshot or delete them. Restore storage.backend: %q, or, if the cluster holds no volumes, set storage.acknowledgeBackendChange: %q to confirm this exact switch." $liveBackend $backend $liveBackend $backend) -}}
|
||||
{{- fail (printf "the live cozystack.linstor Package runs the %q storage backend and this render would switch it to %q. The volumes this cluster already has are known only to the current backend: after the switch the CSI driver cannot attach, resize, snapshot or delete them. Restore storage.backend: %q, or set storage.acknowledgeBackendChange: %q to confirm this exact switch. On a cluster that holds no volumes that is enough. A cluster with LINSTOR volumes moves to blockstor only together with storage.blockstorMigration: hold, in the order packages/system/linstor/README.md gives." $liveBackend $backend $liveBackend $backend) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
@@ -273,10 +273,12 @@ cozystack-scheduler (emitted with its own variant in both branches)
|
||||
LinstorCluster the linstor package renders, the object that points
|
||||
linstor-csi there too, so the names of blockstor's Service and Secret
|
||||
stay in that package alone. Under linstor they get nothing and keep
|
||||
their own defaults, linstor-controller and linstor-client-tls. The
|
||||
backend is passed rather than left to the lookup alone so that a
|
||||
switch changes their values and Helm renders them again. */ -}}
|
||||
{{- if eq (include "cozystack.platform.storage.backend" $root) "blockstor" }}
|
||||
their own defaults, linstor-controller and linstor-client-tls, and so
|
||||
they do while a blockstorMigration is in progress (see
|
||||
blockstorServesApi). The backend is passed rather than left to the
|
||||
lookup alone so that a switch changes their values and Helm renders
|
||||
them again. */ -}}
|
||||
{{- if include "cozystack.platform.storage.blockstorServesApi" $root }}
|
||||
{{- $schedulerComponents := dict "linstor-scheduler" (dict "values" (dict "linstor-scheduler" (dict "linstor" (dict "backend" "blockstor")))) -}}
|
||||
{{include "cozystack.platform.package" (list "cozystack.linstor-scheduler" "default" $root $schedulerComponents) }}
|
||||
{{- else }}
|
||||
@@ -296,6 +298,25 @@ cozystack-scheduler (emitted with its own variant in both branches)
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- /*
|
||||
The migration step for the linstor package, empty when none is in progress.
|
||||
Checked here as well as in the linstor chart, so a typo fails the platform
|
||||
render instead of leaving the cozystack.linstor HelmRelease failing.
|
||||
*/ -}}
|
||||
{{- define "cozystack.platform.storage.blockstorMigration" -}}
|
||||
{{- $migration := "" -}}
|
||||
{{- if and (kindIs "map" .Values.storage) (hasKey .Values.storage "blockstorMigration") -}}
|
||||
{{- $migration = .Values.storage.blockstorMigration -}}
|
||||
{{- end -}}
|
||||
{{- if not (and (kindIs "string" $migration) (has $migration (list "" "hold" "adopt"))) -}}
|
||||
{{- fail (printf "storage.blockstorMigration must be \"\", \"hold\" or \"adopt\", got %#v" $migration) -}}
|
||||
{{- end -}}
|
||||
{{- if and $migration (ne (include "cozystack.platform.storage.backend" .) "blockstor") -}}
|
||||
{{- fail (printf "storage.blockstorMigration %q is only valid with storage.backend: blockstor; remove it together with switching the backend back" $migration) -}}
|
||||
{{- end -}}
|
||||
{{- $migration -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /*
|
||||
Resolve the storage backend for the linstor package.
|
||||
|
||||
@@ -323,6 +344,23 @@ before rendering, so it reads as absent.
|
||||
{{- $backend -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /*
|
||||
Whether the LINSTOR API consumers outside the linstor package are told the
|
||||
blockstor backend, and so follow the LinstorCluster to blockstor-apiserver:
|
||||
backend blockstor once blockstorMigration is cleared, the same step in which
|
||||
piraeus-operator repoints linstor-csi there. Until then LINSTOR's state is the
|
||||
one CSI acts on, while blockstor-apiserver serves nothing (hold, before the
|
||||
converted manifests are in) or Resources it has not adopted yet, with no
|
||||
volume state. linstor-scheduler reads a replica's disk state from the first
|
||||
volume of every Resource of a pod's volume, and on a Resource without volumes
|
||||
it panics rather than answering. Left on the stopped linstor-controller, it
|
||||
fails a scheduling attempt instead, the pod stays Pending and is retried, and
|
||||
nothing is placed on what blockstor half knows.
|
||||
*/ -}}
|
||||
{{- define "cozystack.platform.storage.blockstorServesApi" -}}
|
||||
{{- if and (eq (include "cozystack.platform.storage.backend" .) "blockstor") (not (include "cozystack.platform.storage.blockstorMigration" .)) }}true{{ end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
The block Cilium takes its own addresses from on the kube-ovn variants, the
|
||||
last /21 of the pod CIDR, which kube-ovn is told to exclude. Called with the
|
||||
|
||||
@@ -138,9 +138,12 @@
|
||||
{{include "cozystack.platform.package.full" (list "cozystack.multus" "default" $ $multusComponents) }}
|
||||
{{- end }}
|
||||
{{- if eq (include "cozystack.platform.storage.backend" $) "blockstor" }}
|
||||
{{- $linstorComponents := dict "linstor" (dict "values" (dict "backend" "blockstor")) -}}
|
||||
{{- $linstorValues := dict "backend" "blockstor" -}}
|
||||
{{- with include "cozystack.platform.storage.blockstorMigration" $ }}{{ $_ := set $linstorValues "blockstorMigration" . }}{{ end -}}
|
||||
{{- $linstorComponents := dict "linstor" (dict "values" $linstorValues) -}}
|
||||
{{include "cozystack.platform.package" (list "cozystack.linstor" "default" $ $linstorComponents) }}
|
||||
{{- else }}
|
||||
{{- $_ := include "cozystack.platform.storage.blockstorMigration" $ }}
|
||||
{{include "cozystack.platform.package.default" (list "cozystack.linstor" $) }}
|
||||
{{- end }}
|
||||
{{include "cozystack.platform.package" (list "cozystack.cozystack-scheduler" "linstor" $) }}
|
||||
@@ -239,6 +242,7 @@
|
||||
{{- if eq (include "cozystack.platform.storage.backend" $) "blockstor" -}}
|
||||
{{- $_ := set $linstorValues "backend" "blockstor" -}}
|
||||
{{- end -}}
|
||||
{{- with include "cozystack.platform.storage.blockstorMigration" $ }}{{ $_ := set $linstorValues "blockstorMigration" . }}{{ end -}}
|
||||
{{- $linstorComponents := dict "linstor" (dict "values" $linstorValues) -}}
|
||||
{{include "cozystack.platform.package" (list "cozystack.linstor" "default" $ $linstorComponents) }}
|
||||
{{include "cozystack.platform.package" (list "cozystack.cozystack-scheduler" "linstor" $) }}
|
||||
@@ -527,7 +531,7 @@ variants and opt-in on the slim ones. */}}
|
||||
{{include "cozystack.platform.package.optional.default" (list "cozystack.external-secrets-operator" $) }}
|
||||
{{- /* Told only the backend, as linstor-scheduler is in the common-packages
|
||||
helper: the linstor package's LinstorCluster says where the API is. */ -}}
|
||||
{{- if eq (include "cozystack.platform.storage.backend" $) "blockstor" }}
|
||||
{{- if include "cozystack.platform.storage.blockstorServesApi" $ }}
|
||||
{{- $guiComponents := dict "linstor-gui" (dict "values" (dict "linstor" (dict "backend" "blockstor"))) -}}
|
||||
{{include "cozystack.platform.package.optional.default" (list "cozystack.linstor-gui" $ $guiComponents) }}
|
||||
{{- else }}
|
||||
|
||||
@@ -146,6 +146,59 @@ tests:
|
||||
path: metadata.name
|
||||
value: cozystack.linstor-gui
|
||||
|
||||
# During a migration step LINSTOR's state is still the one CSI acts on, and
|
||||
# blockstor-apiserver serves Resources it has not adopted, which the
|
||||
# scheduler extender cannot read. The consumers move with linstor-csi, when
|
||||
# the step is cleared.
|
||||
- it: leaves the linstor-scheduler on LINSTOR during a migration step
|
||||
set:
|
||||
storage:
|
||||
backend: blockstor
|
||||
blockstorMigration: hold
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
asserts:
|
||||
- notExists:
|
||||
path: spec.components
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: cozystack.linstor-scheduler
|
||||
|
||||
- it: leaves the linstor-scheduler on LINSTOR while adopting on the generic variant
|
||||
set:
|
||||
storage:
|
||||
backend: blockstor
|
||||
blockstorMigration: adopt
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full-generic
|
||||
asserts:
|
||||
- notExists:
|
||||
path: spec.components
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: cozystack.linstor-scheduler
|
||||
|
||||
- it: leaves linstor-gui on LINSTOR during a migration step
|
||||
set:
|
||||
storage:
|
||||
backend: blockstor
|
||||
blockstorMigration: adopt
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
enabledPackages: [cozystack.linstor-gui]
|
||||
asserts:
|
||||
- notExists:
|
||||
path: spec.components
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: cozystack.linstor-gui
|
||||
|
||||
- it: leaves linstor-gui on its defaults under linstor
|
||||
set:
|
||||
bundles:
|
||||
@@ -208,3 +261,107 @@ tests:
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: 'storage must be a map with a backend key, got blockstor'
|
||||
|
||||
# A migration step has to reach the linstor package, which renders piraeus
|
||||
# unchanged while it is set; left behind in the platform it would deploy the
|
||||
# finished switch at once.
|
||||
- it: passes the blockstor migration step through
|
||||
set:
|
||||
storage:
|
||||
backend: blockstor
|
||||
blockstorMigration: hold
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.components.linstor.values
|
||||
value:
|
||||
backend: blockstor
|
||||
blockstorMigration: hold
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: cozystack.linstor
|
||||
|
||||
- it: passes the blockstor migration step through on the generic variant
|
||||
set:
|
||||
storage:
|
||||
backend: blockstor
|
||||
blockstorMigration: adopt
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full-generic
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.components.linstor.values
|
||||
value:
|
||||
backend: blockstor
|
||||
blockstorMigration: adopt
|
||||
talos:
|
||||
enabled: false
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: cozystack.linstor
|
||||
|
||||
# The empty default must not add a key: every blockstor cluster would roll a
|
||||
# new revision of the linstor release for nothing.
|
||||
- it: states no migration step once it is removed
|
||||
set:
|
||||
storage:
|
||||
backend: blockstor
|
||||
blockstorMigration: ""
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.components.linstor.values
|
||||
value:
|
||||
backend: blockstor
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: cozystack.linstor
|
||||
|
||||
- it: fails the render on an unknown migration step
|
||||
set:
|
||||
storage:
|
||||
backend: blockstor
|
||||
blockstorMigration: adopted
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: 'storage.blockstorMigration must be "", "hold" or "adopt", got "adopted"'
|
||||
|
||||
# The way back to linstor has to drop the step in the same change, or the
|
||||
# next switch to blockstor would come up holding.
|
||||
- it: fails the render on a migration step under the linstor backend
|
||||
set:
|
||||
storage:
|
||||
backend: linstor
|
||||
blockstorMigration: hold
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: 'storage.blockstorMigration "hold" is only valid with storage.backend: blockstor; remove it together with switching the backend back'
|
||||
|
||||
- it: fails the render on a migration step under linstor on the generic variant
|
||||
set:
|
||||
storage:
|
||||
backend: linstor
|
||||
blockstorMigration: adopt
|
||||
bundles:
|
||||
system:
|
||||
enabled: true
|
||||
variant: isp-full-generic
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: 'storage.blockstorMigration "adopt" is only valid with storage.backend: blockstor; remove it together with switching the backend back'
|
||||
@@ -111,21 +111,27 @@ migrations:
|
||||
# Which storage control plane the cluster runs.
|
||||
#
|
||||
# linstor — the default, and what every existing cluster runs.
|
||||
# blockstor — EXPERIMENTAL, for new clusters. A
|
||||
# LINSTOR-API-compatible control plane serving the same
|
||||
# CSI driver and StorageClasses. This value does not move
|
||||
# a cluster that already holds LINSTOR volumes: blockstor
|
||||
# adopts them with its own linstor-migrate runbook, which
|
||||
# this platform does not run:
|
||||
# https://blockstor.org/docs/migration/
|
||||
# blockstor — EXPERIMENTAL. A LINSTOR-API-compatible control plane
|
||||
# serving the same CSI driver and StorageClasses. A new
|
||||
# cluster selects it here. A cluster that already holds
|
||||
# LINSTOR volumes moves only through blockstorMigration
|
||||
# below, in the order packages/system/linstor/README.md
|
||||
# gives; changing this value alone does not adopt them.
|
||||
#
|
||||
# Anything else fails the render rather than defaulting, so a typo
|
||||
# cannot quietly deploy the wrong storage control plane. Changing the
|
||||
# backend of a running cluster fails the render too; on a cluster that
|
||||
# holds no volumes yet, set storage.acknowledgeBackendChange to the new
|
||||
# backend to confirm the switch.
|
||||
# backend of a running cluster fails the render too until
|
||||
# storage.acknowledgeBackendChange names the new backend. On a cluster
|
||||
# that holds no volumes yet that confirms the whole switch; on one with
|
||||
# LINSTOR volumes it goes together with blockstorMigration: hold.
|
||||
#
|
||||
# blockstorMigration is set only while blockstor adopts the volumes of a
|
||||
# LINSTOR cluster: "hold", then "adopt", then removed. Until it is removed
|
||||
# the linstor package deploys blockstor but leaves every piraeus object as
|
||||
# it is under linstor. The steps are in packages/system/linstor/README.md.
|
||||
storage:
|
||||
backend: linstor
|
||||
blockstorMigration: ""
|
||||
|
||||
# Bundle deployment configuration
|
||||
bundles:
|
||||
|
||||
Reference in new issue
Block a user