mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-20 15:04:17 +00:00
Make the vsc created by backup sync controller deletable
Fixes #4760 This commit make changes in 2 parts: 1) When a volumesnapshotcontent is persisted during backup, velero will reset its `Source` field to remove the VolumeHandle, so that the csi-snapshotter will not try to call `CreateSnapshot` when its synced to another cluster with a backup. 2) Make sure the referenced volumesnapshotclasses are persisted and synced with the backup, so that when the volumesnapshotcontent is deleted the storage snapshot is also removed. Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
@@ -283,6 +283,22 @@ func (c *backupSyncController) run() {
|
||||
if features.IsEnabled(velerov1api.CSIFeatureFlag) {
|
||||
// we are syncing these objects only to ensure that the storage snapshots are cleaned up
|
||||
// on backup deletion or expiry.
|
||||
log.Info("Syncing CSI volumesnapshotclasses in backup")
|
||||
vsClasses, err := backupStore.GetCSIVolumeSnapshotClasses(backupName)
|
||||
if err != nil {
|
||||
log.WithError(errors.WithStack(err)).Error("Error getting CSI volumesnapclasses for this backup from backup store")
|
||||
continue
|
||||
}
|
||||
for _, vsClass := range vsClasses {
|
||||
vsClass.ResourceVersion = ""
|
||||
created, err := c.csiSnapshotClient.SnapshotV1().VolumeSnapshotClasses().Create(context.TODO(), vsClass, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
log.WithError(errors.WithStack(err)).Errorf("Error syncing volumesnapshotclass %s into cluster", vsClass.Name)
|
||||
continue
|
||||
}
|
||||
log.Infof("Created CSI volumesnapshotclass %s", created.Name)
|
||||
}
|
||||
|
||||
log.Info("Syncing CSI volumesnapshotcontents in backup")
|
||||
snapConts, err := backupStore.GetCSIVolumeSnapshotContents(backupName)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user