mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
feat(linstor): enable VolumeGroupSnapshots for linstor-csi
linstor-csi implements the CSI GroupController since v1.11 and creates the snapshots of a group in one LINSTOR call, so the volumes of a multi-disk VM are captured at the same instant. Velero needs that for application-consistent backups of Windows VMs with three or more disks: taken one by one, the snapshots outlast the 10 s VSS allows a freeze. piraeus-operator decides the csi-snapshotter gate from an API probe it runs only at startup, so on an upgraded cluster the gate would stay off until the operator restarted. The gate is set in the LinstorCluster pod template instead, and a default VolumeGroupSnapshotClass carries the label Velero selects a group snapshot class by. Both render only when the apiserver serves all three v1beta2 group snapshot kinds. With the gate on and the API missing, csi-snapshotter waits for its group snapshot caches before it starts the ordinary snapshot workers, so every VolumeSnapshot would stall, and a v1beta2 VolumeGroupSnapshotClass would fail the upgrade. Otherwise the operator's own probe decides the gate. Assisted-by: LLM Signed-off-by: Mattia Eleuteri <mattia@hidora.io>
This commit is contained in:
5 files changed
+134
-1
No files matched your search
@@ -0,0 +1,13 @@
|
|||||||
|
{{/*
|
||||||
|
Whether the cluster serves the VolumeGroupSnapshot API that csi-snapshotter and
|
||||||
|
Velero use. snapshot-controller can still serve v1alpha1 while this release
|
||||||
|
upgrades: migration 62 keeps a group snapshot CRD that holds objects, and the
|
||||||
|
snapshot-controller release stays Ready on its old revision until it upgrades.
|
||||||
|
With the gate on and the API missing, csi-snapshotter waits for its group
|
||||||
|
snapshot caches before it starts the ordinary snapshot workers.
|
||||||
|
*/}}
|
||||||
|
{{- define "linstor.groupSnapshotAPIServed" -}}
|
||||||
|
{{- if and (.Capabilities.APIVersions.Has "groupsnapshot.storage.k8s.io/v1beta2/VolumeGroupSnapshot") (.Capabilities.APIVersions.Has "groupsnapshot.storage.k8s.io/v1beta2/VolumeGroupSnapshotContent") (.Capabilities.APIVersions.Has "groupsnapshot.storage.k8s.io/v1beta2/VolumeGroupSnapshotClass") -}}
|
||||||
|
true
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
@@ -89,6 +89,16 @@ spec:
|
|||||||
containers:
|
containers:
|
||||||
- name: linstor-csi
|
- name: linstor-csi
|
||||||
image: {{ .Values.linstorCSI.image.repository }}:{{ .Values.linstorCSI.image.tag }}
|
image: {{ .Values.linstorCSI.image.repository }}:{{ .Values.linstorCSI.image.tag }}
|
||||||
|
{{- /* piraeus-operator probes groupsnapshot.storage.k8s.io/v1beta2
|
||||||
|
once, when it starts, and only for VolumeGroupSnapshot. Its
|
||||||
|
answer goes stale when the CRDs change after it started, and it
|
||||||
|
turns the gate on when that one kind is served without the
|
||||||
|
content or class kind. The gate is therefore always decided
|
||||||
|
here, from all three kinds. */}}
|
||||||
|
- name: csi-snapshotter
|
||||||
|
env:
|
||||||
|
- name: FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT
|
||||||
|
value: {{ include "linstor.groupSnapshotAPIServed" . | default "false" | quote }}
|
||||||
{{- if .Values.linstorCSI.strictTopology }}
|
{{- if .Values.linstorCSI.strictTopology }}
|
||||||
{{- /* A `#` comment in a rendered template is part of the output: it
|
{{- /* A `#` comment in a rendered template is part of the output: it
|
||||||
is applied to the live LinstorCluster and read back on every
|
is applied to the live LinstorCluster and read back on every
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{{- if include "linstor.groupSnapshotAPIServed" . }}
|
||||||
|
apiVersion: groupsnapshot.storage.k8s.io/v1beta2
|
||||||
|
kind: VolumeGroupSnapshotClass
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
groupsnapshot.storage.kubernetes.io/is-default-class: "true"
|
||||||
|
labels:
|
||||||
|
velero.io/csi-volumegroupsnapshot-class: "true"
|
||||||
|
name: linstor-group-snapshots
|
||||||
|
driver: linstor.csi.linbit.com
|
||||||
|
deletionPolicy: Delete
|
||||||
|
{{- end }}
|
||||||
@@ -55,7 +55,10 @@ tests:
|
|||||||
asserts:
|
asserts:
|
||||||
- lengthEqual:
|
- lengthEqual:
|
||||||
path: spec.csiController.podTemplate.spec.containers
|
path: spec.csiController.podTemplate.spec.containers
|
||||||
count: 1
|
count: 2
|
||||||
- equal:
|
- equal:
|
||||||
path: spec.csiController.podTemplate.spec.containers[0].name
|
path: spec.csiController.podTemplate.spec.containers[0].name
|
||||||
value: linstor-csi
|
value: linstor-csi
|
||||||
|
- equal:
|
||||||
|
path: spec.csiController.podTemplate.spec.containers[1].name
|
||||||
|
value: csi-snapshotter
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
suite: VolumeGroupSnapshot support for linstor-csi
|
||||||
|
|
||||||
|
# piraeus-operator decides FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT for the
|
||||||
|
# csi-snapshotter sidecar from an API probe it runs only at startup, so an
|
||||||
|
# operator that started before snapshot-controller served
|
||||||
|
# groupsnapshot.storage.k8s.io/v1beta2 leaves the gate off. The podTemplate
|
||||||
|
# always sets it, on only when all three v1beta2 kinds are served: the probe
|
||||||
|
# checks VolumeGroupSnapshot alone, and the gate on without the content or class
|
||||||
|
# API stalls csi-snapshotter. The VolumeGroupSnapshotClass carries the label
|
||||||
|
# Velero selects a group snapshot class by, and is not rendered while the API is
|
||||||
|
# missing, where it would fail the upgrade.
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: "csi-snapshotter gets the CSIVolumeGroupSnapshot gate once v1beta2 is served"
|
||||||
|
template: templates/cluster.yaml
|
||||||
|
capabilities: &v1beta2
|
||||||
|
apiVersions:
|
||||||
|
- groupsnapshot.storage.k8s.io/v1beta2/VolumeGroupSnapshot
|
||||||
|
- groupsnapshot.storage.k8s.io/v1beta2/VolumeGroupSnapshotContent
|
||||||
|
- groupsnapshot.storage.k8s.io/v1beta2/VolumeGroupSnapshotClass
|
||||||
|
asserts:
|
||||||
|
- contains:
|
||||||
|
path: spec.csiController.podTemplate.spec.containers
|
||||||
|
content:
|
||||||
|
name: csi-snapshotter
|
||||||
|
env:
|
||||||
|
- name: FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT
|
||||||
|
value: "true"
|
||||||
|
|
||||||
|
- it: "csi-snapshotter gate is kept when strict topology is disabled"
|
||||||
|
template: templates/cluster.yaml
|
||||||
|
capabilities: *v1beta2
|
||||||
|
set:
|
||||||
|
linstorCSI:
|
||||||
|
strictTopology: false
|
||||||
|
asserts:
|
||||||
|
- contains:
|
||||||
|
path: spec.csiController.podTemplate.spec.containers
|
||||||
|
content:
|
||||||
|
name: csi-snapshotter
|
||||||
|
env:
|
||||||
|
- name: FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT
|
||||||
|
value: "true"
|
||||||
|
|
||||||
|
- it: "csi-snapshotter gate is off when only VolumeGroupSnapshot serves v1beta2"
|
||||||
|
template: templates/cluster.yaml
|
||||||
|
capabilities:
|
||||||
|
apiVersions:
|
||||||
|
- groupsnapshot.storage.k8s.io/v1beta2/VolumeGroupSnapshot
|
||||||
|
asserts:
|
||||||
|
- contains:
|
||||||
|
path: spec.csiController.podTemplate.spec.containers
|
||||||
|
content:
|
||||||
|
name: csi-snapshotter
|
||||||
|
env:
|
||||||
|
- name: FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT
|
||||||
|
value: "false"
|
||||||
|
|
||||||
|
- it: "csi-snapshotter gate is off when the API is not served at all"
|
||||||
|
template: templates/cluster.yaml
|
||||||
|
asserts:
|
||||||
|
- contains:
|
||||||
|
path: spec.csiController.podTemplate.spec.containers
|
||||||
|
content:
|
||||||
|
name: csi-snapshotter
|
||||||
|
env:
|
||||||
|
- name: FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT
|
||||||
|
value: "false"
|
||||||
|
|
||||||
|
- it: "linstor VolumeGroupSnapshotClass is the default class Velero selects"
|
||||||
|
template: templates/volumegroupsnapshotclass.yaml
|
||||||
|
capabilities: *v1beta2
|
||||||
|
asserts:
|
||||||
|
- isKind:
|
||||||
|
of: VolumeGroupSnapshotClass
|
||||||
|
- isAPIVersion:
|
||||||
|
of: groupsnapshot.storage.k8s.io/v1beta2
|
||||||
|
- equal:
|
||||||
|
path: driver
|
||||||
|
value: linstor.csi.linbit.com
|
||||||
|
- equal:
|
||||||
|
path: deletionPolicy
|
||||||
|
value: Delete
|
||||||
|
- equal:
|
||||||
|
path: metadata.labels["velero.io/csi-volumegroupsnapshot-class"]
|
||||||
|
value: "true"
|
||||||
|
- equal:
|
||||||
|
path: metadata.annotations["groupsnapshot.storage.kubernetes.io/is-default-class"]
|
||||||
|
value: "true"
|
||||||
|
|
||||||
|
- it: "no VolumeGroupSnapshotClass while v1beta2 is not served"
|
||||||
|
template: templates/volumegroupsnapshotclass.yaml
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
Reference in new issue
Block a user