vmware-tanzu / velero

Backup and migrate Kubernetes applications and their persistent volumes
https://velero.io
Apache License 2.0
8.78k stars 1.41k forks source link

ChangeStorageClassAction doesn't affect VolumeType of restored volume #8164

Open Lirt opened 2 months ago

Lirt commented 2 months ago

What steps did you take and what happened: Hello, Lirt here from Velero plugin for Openstack.

Users of Openstack plugin experienced an interesting fact that is a question whether it is a bug or undocumented behavior.

There is an action to change PV/PVC storage class in Velero. In the code I found it under name ChangeStorageClassAction. This action is supposed to change PV/PVC storage class. The user of Openstack plugin expected that this will also affect the volumeType of the volume, but this didn't happen (function in the plugin example).

Based on my research the Velero code first executes volume restore and then it loops over actions and executes them. This means that change of storage class doesn't affect volume type of restored volume.

Is this a misconception that the user has about the behavior or does it make sense that the volumeType should be changed by the action (or different action)?

Reference GH Issue from Openstack plugin - https://github.com/Lirt/velero-plugin-for-openstack/issues/113

What did you expect to happen:

velero.io/change-storage-class: RestoreItemAction changes volume type of restored volume.

The following information will help us better understand what's going on:

Velero version(velero version): 1.13.2 Plugin version(Openstack plugin): v0.7.0 Kubernetes version(kubectl version): v1.26.15

sseago commented 2 months ago

RestoreItemActions run on each matching resource before the resource is restored. So the storage class of the PVC should have been updated before it was created in the cluster. The only thing that this changes, though, is the StorageClassName field, which should affect which storage class is used to bind a new PV to the PVC when the PVC is created.

For the CSI snapshot and fs-backup use cases, the PV is actually discarded and a new PV is provisioned. If you are using a volume snapshotter plugin instead, then things may work differently -- I'm less familiar with the lower-level workflow in that case. I don't know that I've ever tried changing storageclass in that case, but I wouldn't expect it to work in most cases, since native snapshots are specific to the storage provider used, so if you restore with a different storage class, the new storage class may be a completely different storage type, so the snapshot may not even be compatible.

ywk253100 commented 2 months ago

The volumeType used during the restoration is read from the backup (backups/backup-name/backup-name-volumesnapshots.json.gz, it is used when running the volume snapshot plugin, the ChangeStorageClassAction doesn't change it. )

ankitsharma1133 commented 1 week ago

hi @ywk253100
Do we have any further updates on this . I am also facing using similar issue for azure disk with changing the storage class for PVCs during Velero restores. , I am trying to change the storage class from the default StandardSSD_LRS to StandardSSD_ZRS. The storage class is update but new pv is created with old sku/type