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

## What this PR does

The linstor group snapshot gate and the linstor
`VolumeGroupSnapshotClass` were tied to
`groupsnapshot.storage.k8s.io/v1beta2`, on the grounds that
piraeus-operator probes v1beta2. On main it does not: piraeus-operator
v2.12.1 probes v1, csi-snapshotter v8.7.0 reads the content and class
kinds at v1, and snapshot-controller v8.7.0 watches all three kinds at
v1. The vendored chart serves v1, v1beta1 and v1beta2 today, so nothing
is broken yet, but once upstream stops serving v1beta2 the gate would
turn group snapshots off while every component that acts on them could
still use them.

The first commit gates on v1 and moves the class to v1. It also replaces
the comment that said csi-snapshotter stalls when the gate is on and the
API is missing: v8.7.0 logs a warning and runs without group snapshots.
Velero 1.18 reads group snapshots at v1beta2, so the vm-instance hook,
which gates on v1beta2 for Velero, stays as it is.

The second commit rewrites the snapshot-controller CRD test. It pinned
the vendored chart's layout (six CRD documents, v1beta2 as the storage
version, no v1alpha1) and would go red on a correct `make update` that
moves storage to v1. It now asserts what the platform needs: every group
snapshot CRD serves v1 and v1beta2, the three volume snapshot CRDs are
rendered, and every rendered CRD is kept on uninstall.

On upgrade, an install running the CRDs from this chart sees no change
in the gate and no csi-controller rollout. The class is updated in
place, since Helm matches release objects by group and kind. The only
install that flips is one whose distribution ships group snapshot CRDs
with v1beta2 but not v1: the gate goes from on to off and the class is
removed, and csi-snapshotter there was already disabling the feature at
startup.

I left the `-eq 3` check in the platform `image-migrations` target
alone. It stops an image from shipping where migration 62 deletes the
old CRDs and has nothing to recreate them from; asserting the three file
names instead would copy the list migration 62 already holds, and the
count fails loudly if upstream adds a CRD.

Tested with `helm unittest` on `packages/system/linstor` and
`packages/system/snapshot-controller`. I also checked that the new CRD
test fails when v1 or v1beta2 stops being served, when `keepCRDs` is
false, and when no CRD renders. Nothing was run against a cluster.

### Screenshots

Not a UI change.

### Downstream repositories

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(linstor): enable volume group snapshots based on the groupsnapshot.storage.k8s.io/v1 API that csi-snapshotter and snapshot-controller use, so they keep working once upstream stops serving v1beta2.
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **New Features**
* LINSTOR group snapshot support now uses the stable
`groupsnapshot.storage.k8s.io/v1` API when all required resources are
available.
* Group snapshot resources are served through both v1 and v1beta2,
supporting components that use either API version.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Aleksei Sviridkin authored and GitHub committed 2026-11-25 19:52:11 +03:00
commit 054b4ef4bc
6 files changed
+83 -51

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:
@@ -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