fix(linstor): gate group snapshots on the v1 group snapshot API

The CSIVolumeGroupSnapshot gate for csi-snapshotter and the linstor
VolumeGroupSnapshotClass were rendered only when
groupsnapshot.storage.k8s.io/v1beta2 is served. The components that
act on group snapshots read v1: csi-snapshotter v8.7.0 builds its
content and class informers on v1 and checks for those v1 kinds at
startup, snapshot-controller v8.7.0 watches all three kinds at v1, and
piraeus-operator v2.12.1 probes v1 VolumeGroupSnapshot. The chart
serves v1, v1beta1 and v1beta2 today, so the outcome is the same, but
once upstream stops serving v1beta2 the gate would switch group
snapshots off while every consumer could still use them. A
distribution that serves v1beta2 without v1 got the gate on, and
csi-snapshotter then disabled the feature at startup anyway.

The class moves to v1 with the gate. Helm matches release objects by
group and kind, so the existing class is updated in place. Velero
1.18 still reads the class at v1beta2, which the chart serves.

The comment claiming csi-snapshotter stalls with the gate on and the
API missing is replaced: v8.7.0 logs a warning and runs without group
snapshots. What the render-time gate buys is a csi-controller rollout
on the first linstor upgrade that sees the API, because csi-snapshotter
looks for it only when it starts.

Tested with helm unittest on packages/system/linstor; a cluster
serving the three kinds at v1beta2 only now renders the gate off and no
class.

Fixes: d89bce58e8 ("feat(linstor): enable VolumeGroupSnapshots for linstor-csi")
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
Aleksei Sviridkin committed 2026-11-25 12:22:57 +03:00
1 parent ba0ff0f8e8
commit 08c22a2f99
5 files changed
+45 -31

No files matched your search

@@ -26,7 +26,7 @@
# into the image (see image-migrations in the platform Makefile), already
# carrying the release's ownership metadata. Every HelmRelease waits for this
# hook, so the linstor release, which renders its group snapshot gate and
# VolumeGroupSnapshotClass only when the v1beta2 API is served, renders against
# VolumeGroupSnapshotClass only when the v1 API is served, renders against
# it even when it upgrades before snapshot-controller. When a CRD was kept, none
# is created here, the release creates the missing ones, and linstor renders
# the gate off. Recovery is by hand, since nothing renders either release again
@@ -1,13 +1,14 @@
{{/*
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.
Whether the cluster serves the groupsnapshot.storage.k8s.io/v1 API that
csi-snapshotter and snapshot-controller read. 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. Leaving the gate off until then, rather than
always on, makes the first linstor upgrade that sees the API roll the
csi-controller: csi-snapshotter looks for the API only when it starts.
*/}}
{{- 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") -}}
{{- if and (.Capabilities.APIVersions.Has "groupsnapshot.storage.k8s.io/v1/VolumeGroupSnapshot") (.Capabilities.APIVersions.Has "groupsnapshot.storage.k8s.io/v1/VolumeGroupSnapshotContent") (.Capabilities.APIVersions.Has "groupsnapshot.storage.k8s.io/v1/VolumeGroupSnapshotClass") -}}
true
{{- end -}}
{{- end -}}
@@ -89,12 +89,10 @@ spec:
containers:
- name: linstor-csi
image: {{ .Values.linstorCSI.image.repository }}:{{ .Values.linstorCSI.image.tag }}
{{- /* piraeus-operator probes groupsnapshot.storage.k8s.io/v1beta2
{{- /* piraeus-operator probes groupsnapshot.storage.k8s.io/v1
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. */}}
answer goes stale when the CRDs change after it started, so the
gate is always decided here, from all three kinds. */}}
- name: csi-snapshotter
env:
- name: FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT
@@ -1,5 +1,5 @@
{{- if include "linstor.groupSnapshotAPIServed" . }}
apiVersion: groupsnapshot.storage.k8s.io/v1beta2
apiVersion: groupsnapshot.storage.k8s.io/v1
kind: VolumeGroupSnapshotClass
metadata:
annotations:
@@ -2,22 +2,21 @@ 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.
# operator that started before snapshot-controller served the group snapshot
# API leaves the gate off. The podTemplate always sets it, on only when all
# three groupsnapshot.storage.k8s.io/v1 kinds are served, the version
# csi-snapshotter and snapshot-controller read. 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"
- it: "csi-snapshotter gets the CSIVolumeGroupSnapshot gate once v1 is served"
template: templates/cluster.yaml
capabilities: &v1beta2
capabilities: &v1
apiVersions:
- groupsnapshot.storage.k8s.io/v1beta2/VolumeGroupSnapshot
- groupsnapshot.storage.k8s.io/v1beta2/VolumeGroupSnapshotContent
- groupsnapshot.storage.k8s.io/v1beta2/VolumeGroupSnapshotClass
- groupsnapshot.storage.k8s.io/v1/VolumeGroupSnapshot
- groupsnapshot.storage.k8s.io/v1/VolumeGroupSnapshotContent
- groupsnapshot.storage.k8s.io/v1/VolumeGroupSnapshotClass
asserts:
- contains:
path: spec.csiController.podTemplate.spec.containers
@@ -29,7 +28,7 @@ tests:
- it: "csi-snapshotter gate is kept when strict topology is disabled"
template: templates/cluster.yaml
capabilities: *v1beta2
capabilities: *v1
set:
linstorCSI:
strictTopology: false
@@ -42,11 +41,27 @@ tests:
- name: FEATURE_GATE_CSI_VOLUME_GROUP_SNAPSHOT
value: "true"
- it: "csi-snapshotter gate is off when only VolumeGroupSnapshot serves v1beta2"
- it: "csi-snapshotter gate is off when only VolumeGroupSnapshot serves v1"
template: templates/cluster.yaml
capabilities:
apiVersions:
- groupsnapshot.storage.k8s.io/v1/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 served at v1beta2 only"
template: templates/cluster.yaml
capabilities:
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
@@ -69,12 +84,12 @@ tests:
- it: "linstor VolumeGroupSnapshotClass is the default class Velero selects"
template: templates/volumegroupsnapshotclass.yaml
capabilities: *v1beta2
capabilities: *v1
asserts:
- isKind:
of: VolumeGroupSnapshotClass
- isAPIVersion:
of: groupsnapshot.storage.k8s.io/v1beta2
of: groupsnapshot.storage.k8s.io/v1
- equal:
path: driver
value: linstor.csi.linbit.com
@@ -88,7 +103,7 @@ tests:
path: metadata.annotations["groupsnapshot.storage.kubernetes.io/is-default-class"]
value: "true"
- it: "no VolumeGroupSnapshotClass while v1beta2 is not served"
- it: "no VolumeGroupSnapshotClass while v1 is not served"
template: templates/volumegroupsnapshotclass.yaml
asserts:
- hasDocuments: