Skip to content

Commit 117b9d2

Browse files
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. Assisted-by: LLM Signed-off-by: Mattia Eleuteri <[email protected]>
1 parent 198d8ac commit 117b9d2

4 files changed

Lines changed: 80 additions & 1 deletion

File tree

‎packages/system/linstor/templates/cluster.yaml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,17 @@ spec:
8383
containers:
8484
- name: linstor-csi
8585
image: {{ .Values.linstorCSI.image.repository }}:{{ .Values.linstorCSI.image.tag }}
86+
{{- /* piraeus-operator probes the groupsnapshot.storage.k8s.io/v1beta2
87+
API once, when it starts, and turns this gate off when the API
88+
is not served. On a cluster upgraded from the v1alpha1 CRDs the
89+
operator started before snapshot-controller replaced them, so
90+
the gate would stay off until the operator next restarted. This
91+
package depends on snapshot-controller, which serves v1beta2, so
92+
the gate is set here rather than left to that probe. */}}
93+
- name: csi-snapshotter
94+
env:
95+
- name: FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT
96+
value: "true"
8697
{{- if .Values.linstorCSI.strictTopology }}
8798
{{- /* A `#` comment in a rendered template is part of the output: it
8899
is applied to the live LinstorCluster and read back on every
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: groupsnapshot.storage.k8s.io/v1beta2
2+
kind: VolumeGroupSnapshotClass
3+
metadata:
4+
annotations:
5+
groupsnapshot.storage.kubernetes.io/is-default-class: "true"
6+
labels:
7+
velero.io/csi-volumegroupsnapshot-class: "true"
8+
name: linstor-group-snapshots
9+
driver: linstor.csi.linbit.com
10+
deletionPolicy: Delete

‎packages/system/linstor/tests/csi-topology_test.yaml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ tests:
5555
asserts:
5656
- lengthEqual:
5757
path: spec.csiController.podTemplate.spec.containers
58-
count: 1
58+
count: 2
5959
- equal:
6060
path: spec.csiController.podTemplate.spec.containers[0].name
6161
value: linstor-csi
62+
- equal:
63+
path: spec.csiController.podTemplate.spec.containers[1].name
64+
value: csi-snapshotter
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
suite: VolumeGroupSnapshot support for linstor-csi
2+
3+
# piraeus-operator decides FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT for the
4+
# csi-snapshotter sidecar from an API probe it runs only at startup, so an
5+
# operator that started before snapshot-controller served
6+
# groupsnapshot.storage.k8s.io/v1beta2 leaves the gate off. The podTemplate
7+
# below is merged after the operator's own patch and sets it explicitly, and
8+
# the VolumeGroupSnapshotClass carries the label Velero selects a group
9+
# snapshot class by.
10+
11+
tests:
12+
- it: "csi-snapshotter gets the CSIVolumeGroupSnapshot gate from the podTemplate"
13+
template: templates/cluster.yaml
14+
asserts:
15+
- contains:
16+
path: spec.csiController.podTemplate.spec.containers
17+
content:
18+
name: csi-snapshotter
19+
env:
20+
- name: FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT
21+
value: "true"
22+
23+
- it: "csi-snapshotter gate is kept when strict topology restates the provisioner args"
24+
template: templates/cluster.yaml
25+
set:
26+
linstorCSI:
27+
strictTopology: true
28+
asserts:
29+
- contains:
30+
path: spec.csiController.podTemplate.spec.containers
31+
content:
32+
name: csi-snapshotter
33+
env:
34+
- name: FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT
35+
value: "true"
36+
37+
- it: "linstor VolumeGroupSnapshotClass is the default class Velero selects"
38+
template: templates/volumegroupsnapshotclass.yaml
39+
asserts:
40+
- isKind:
41+
of: VolumeGroupSnapshotClass
42+
- isAPIVersion:
43+
of: groupsnapshot.storage.k8s.io/v1beta2
44+
- equal:
45+
path: driver
46+
value: linstor.csi.linbit.com
47+
- equal:
48+
path: deletionPolicy
49+
value: Delete
50+
- equal:
51+
path: metadata.labels["velero.io/csi-volumegroupsnapshot-class"]
52+
value: "true"
53+
- equal:
54+
path: metadata.annotations["groupsnapshot.storage.kubernetes.io/is-default-class"]
55+
value: "true"

0 commit comments

Comments
 (0)