From 08c22a2f99a6f96dfcc4fb464d23b206d56c12d3 Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Wed, 25 Nov 2026 12:22:57 +0300 Subject: [PATCH 1/2] 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: d89bce58e878 ("feat(linstor): enable VolumeGroupSnapshots for linstor-csi") Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- .../platform/images/migrations/migrations/62 | 2 +- .../system/linstor/templates/_helpers.tpl | 15 +++--- .../system/linstor/templates/cluster.yaml | 8 ++- .../templates/volumegroupsnapshotclass.yaml | 2 +- .../tests/volume_group_snapshot_test.yaml | 49 ++++++++++++------- 5 files changed, 45 insertions(+), 31 deletions(-) diff --git a/packages/core/platform/images/migrations/migrations/62 b/packages/core/platform/images/migrations/migrations/62 index 38faf333e..70998dba6 100755 --- a/packages/core/platform/images/migrations/migrations/62 +++ b/packages/core/platform/images/migrations/migrations/62 @@ -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 diff --git a/packages/system/linstor/templates/_helpers.tpl b/packages/system/linstor/templates/_helpers.tpl index c72f00420..a0c466248 100644 --- a/packages/system/linstor/templates/_helpers.tpl +++ b/packages/system/linstor/templates/_helpers.tpl @@ -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 -}} diff --git a/packages/system/linstor/templates/cluster.yaml b/packages/system/linstor/templates/cluster.yaml index 72ac70493..4639e677b 100644 --- a/packages/system/linstor/templates/cluster.yaml +++ b/packages/system/linstor/templates/cluster.yaml @@ -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 diff --git a/packages/system/linstor/templates/volumegroupsnapshotclass.yaml b/packages/system/linstor/templates/volumegroupsnapshotclass.yaml index bae3416cd..e98890fcd 100644 --- a/packages/system/linstor/templates/volumegroupsnapshotclass.yaml +++ b/packages/system/linstor/templates/volumegroupsnapshotclass.yaml @@ -1,5 +1,5 @@ {{- if include "linstor.groupSnapshotAPIServed" . }} -apiVersion: groupsnapshot.storage.k8s.io/v1beta2 +apiVersion: groupsnapshot.storage.k8s.io/v1 kind: VolumeGroupSnapshotClass metadata: annotations: diff --git a/packages/system/linstor/tests/volume_group_snapshot_test.yaml b/packages/system/linstor/tests/volume_group_snapshot_test.yaml index 096dfd8b6..b31d68033 100644 --- a/packages/system/linstor/tests/volume_group_snapshot_test.yaml +++ b/packages/system/linstor/tests/volume_group_snapshot_test.yaml @@ -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: From 90e52bb6338a36472f8834688c424d6f4dcbaaf1 Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Wed, 25 Nov 2026 12:23:06 +0300 Subject: [PATCH 2/2] test(snapshot-controller): assert the group snapshot versions consumers read The CRD test pinned the vendored chart's layout: exactly six CRD documents, v1beta2 as the storage version of each group snapshot CRD and no v1alpha1. None of that is something the platform relies on, and an upstream release that moves storage to v1 or adds a CRD would turn the test red on a correct make update. What the platform needs is that each group snapshot CRD serves v1, which snapshot-controller, csi-snapshotter and the linstor gate read, and v1beta2, which Velero 1.18 and the vm-instance hook read. The test now asserts those two served versions, that the three volume snapshot CRDs CDI and the CSI drivers read are rendered, and that every rendered CRD is kept on uninstall, without counting documents. Removing either served version, dropping a volume snapshot CRD, setting keepCRDs to false, or rendering no CRDs fails it. Fixes: 892d9c9b343b ("feat(platform): upgrade snapshot-controller to v8.7.0") Assisted-by: LLM Signed-off-by: Aleksei Sviridkin --- .../snapshot-controller/tests/crds_test.yaml | 58 ++++++++++++------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/packages/system/snapshot-controller/tests/crds_test.yaml b/packages/system/snapshot-controller/tests/crds_test.yaml index 598d02bbe..202f0901c 100644 --- a/packages/system/snapshot-controller/tests/crds_test.yaml +++ b/packages/system/snapshot-controller/tests/crds_test.yaml @@ -2,9 +2,10 @@ suite: snapshot CRDs and the VolumeGroupSnapshot gate # The vendored chart renders the snapshot CRDs from a template, so they belong # to this release: keepCRDs stops an uninstall from taking every VolumeSnapshot -# with them. Velero 1.18 and piraeus-operator both look for -# groupsnapshot.storage.k8s.io/v1beta2, and the controller only acts on group -# snapshots with the CSIVolumeGroupSnapshot gate on. +# with them. The group snapshot API is read at v1 by snapshot-controller, +# csi-snapshotter and the linstor gate, and at v1beta2 by Velero 1.18 and the +# vm-instance hook. The controller only acts on group snapshots with the +# CSIVolumeGroupSnapshot gate on. templates: - charts/snapshot-controller/templates/crds.yaml @@ -14,13 +15,30 @@ tests: - it: every CRD is kept on uninstall template: charts/snapshot-controller/templates/crds.yaml asserts: - - hasDocuments: - count: 6 - equal: path: metadata.annotations["helm.sh/resource-policy"] value: keep - - it: volumegroupsnapshots serves v1beta2 and no longer v1alpha1 + - it: the volume snapshot CRDs CDI and the CSI drivers read are rendered + template: charts/snapshot-controller/templates/crds.yaml + asserts: + - containsDocument: + apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: volumesnapshots.snapshot.storage.k8s.io + any: true + - containsDocument: + apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: volumesnapshotcontents.snapshot.storage.k8s.io + any: true + - containsDocument: + apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: volumesnapshotclasses.snapshot.storage.k8s.io + any: true + + - it: volumegroupsnapshots serves v1 and v1beta2 template: charts/snapshot-controller/templates/crds.yaml documentSelector: path: metadata.name @@ -29,17 +47,17 @@ tests: - contains: path: spec.versions content: - name: v1beta2 + name: v1 served: true - storage: true any: true - - notContains: + - contains: path: spec.versions content: - name: v1alpha1 + name: v1beta2 + served: true any: true - - it: volumegroupsnapshotcontents serves v1beta2 and no longer v1alpha1 + - it: volumegroupsnapshotcontents serves v1 and v1beta2 template: charts/snapshot-controller/templates/crds.yaml documentSelector: path: metadata.name @@ -48,17 +66,17 @@ tests: - contains: path: spec.versions content: - name: v1beta2 + name: v1 served: true - storage: true any: true - - notContains: + - contains: path: spec.versions content: - name: v1alpha1 + name: v1beta2 + served: true any: true - - it: volumegroupsnapshotclasses serves v1beta2 and no longer v1alpha1 + - it: volumegroupsnapshotclasses serves v1 and v1beta2 template: charts/snapshot-controller/templates/crds.yaml documentSelector: path: metadata.name @@ -67,14 +85,14 @@ tests: - contains: path: spec.versions content: - name: v1beta2 + name: v1 served: true - storage: true any: true - - notContains: + - contains: path: spec.versions content: - name: v1alpha1 + name: v1beta2 + served: true any: true - it: the controller runs with the CSIVolumeGroupSnapshot gate