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: