-
Notifications
You must be signed in to change notification settings - Fork 385
hep: Harvester CSI Volume Snpshot Supprt [skip ci] #9125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
hep: Harvester CSI Volume Snpshot Supprt [skip ci] #9125
Conversation
Signed-off-by: Webber Huang <[email protected]> Co-authored-by: Ivan Sim <[email protected]>
6f0ccc7 to
b3f17f1
Compare
|
Hi @ihcsim, Thanks for the feedback! I’ve replied to and applied your suggestions and questions—please take a look. |
| Snapshots created by the driver include essential metadata labels: | ||
| - `harvesterhci.io/snapHostSC`: Original storage class name | ||
| - `harvesterhci.io/snapHostStorage`: Original volume capacity | ||
| - `harvesterhci.io/snapHostVolumeMode`: Original volume mode (Block/Filesystem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During snapshot restore, the volume mode can be derived from the volume snapshot content's .spec.sourceVolumeMode field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field may not be populated—it seems to depend on the CSI driver. These manifests are from my environment.
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotContent
metadata:
name: snapcontent-a86c8a81-96ee-456a-b09b-0f8875a39c67
spec:
deletionPolicy: Delete
driver: driver.longhorn.io
source:
volumeHandle: pvc-9ae5d635-cd0a-4795-ae7f-b68e26bd850d
volumeSnapshotClassName: longhorn-snapshot
volumeSnapshotRef:
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
name: snapshot-057280cb-2346-4cb8-969a-9744037358c6
namespace: default
resourceVersion: "53038639"
uid: a86c8a81-96ee-456a-b09b-0f8875a39c67
status:
creationTime: 1758785089000000000
readyToUse: true
restoreSize: 2147483648
snapshotHandle: snap://pvc-9ae5d635-cd0a-4795-ae7f-b68e26bd850d/snapshot-a86c8a81-96ee-456a-b09b-0f8875a39c67
and
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotContent
metadata:
creationTimestamp: "2025-09-25T08:12:53Z"
finalizers:
- snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection
generation: 1
name: snapcontent-cb6b8087-1fe5-4410-9d08-c5efca0a7fdd
resourceVersion: "4417662"
uid: 5e005c30-a1ef-4e57-bfce-a3750df40b80
spec:
deletionPolicy: Delete
driver: driver.harvesterhci.io
source:
volumeHandle: pvc-e5ced3a0-1537-4fab-9b74-9d70a6dd3900
sourceVolumeMode: Filesystem
volumeSnapshotClassName: harvester-snapshot
volumeSnapshotRef:
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
name: snapshot-fs-vol
namespace: default
resourceVersion: "4417147"
uid: cb6b8087-1fe5-4410-9d08-c5efca0a7fdd
status:
creationTime: 1758787988000000000
readyToUse: true
restoreSize: 1972171
snapshotHandle: snapshot-cb6b8087-1fe5-4410-9d08-c5efca0a7fdd
Since the Harvester CSI driver still requires the annotation for the host StorageClass, I prefer to keep the current design.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update on why .spec.sourceVolumeMode isn’t always populated:
it’s set by the snapshot-controller only when the PreventVolumeModeConversion feature gate is enabled and the source PV defines volumeMode. See the relevant code in snapshot_controller.go (L775–L780).
The PreventVolumeModeConversion feature gate has been enabled by default since v7.0, as noted in the CHANGELOG 7.0.
- Enable prevent-volume-mode-conversion feature flag by default.
Volume mode change will be rejected when creating a PVC from a VolumeSnapshot unless the AllowVolumeModeChange annotation has been set to true
Since Harvester v1.6.0 uses snapshotter v6.3.3, the PreventVolumeModeConversion feature gate is disabled by default. If we update Harvester’s snapshot-controller deployment with it enabled, .spec.sourceVolumeMode will then be populated whenever the source PV defines volumeMode:
apiVersion: apps/v1
kind: Deployment
metadata:
name: snapshot-controller
namespace: kube-system
spec:
template:
spec:
containers:
- name: snapshot-controller
image: registry.k8s.io/sig-storage/snapshot-controller:v6.3.3
args:
- --v=5
- --leader-election=true
- --prevent-volume-mode-conversion=true # Added this line
All subsequent VSCs will be populated with .spec.sourceVolumeMode.
Back to the original discussion: since the presence of .spec.sourceVolumeMode in a VSC depends on the snapshot controller’s deployment, IMO, Harvester CSI shouldn’t rely on this field.
Instead, the Harvester CSI driver could leverage the label on the host CSI snapshot for more flexibility in determining the correct volume mode during snapshot restore. cc @Vicente-Cheng
|
|
||
| Snapshots created by the driver include essential metadata labels: | ||
| - `harvesterhci.io/snapHostSC`: Original storage class name | ||
| - `harvesterhci.io/snapHostStorage`: Original volume capacity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the volume snapshot content's .status.restoreSize when restoring the snapshot to a PVC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto, since the Harvester CSI driver still requires the annotation for the host StorageClass, I prefer to keep the current design.
Solution:
HEP for Harvester CSI Snapshot Support
Related Issue(s):
#3778