Skip to content

Commit

Permalink
pb-4093 Deleting the volumesnapshotcontent in the case of failed native
Browse files Browse the repository at this point in the history
CSI backup

	- Adding the vsc name in the map in CleanupBackupResources with
	  out any status check ( success/failure/in-progress)
	- In SnapshotStatus() also removed the check for ready state to
	  add the volumesnapshotcontent name in the snapshotInfo. If the status
	  volumesnapshotcontent is present, we will add the VSC name in the snapshotInfo.
  • Loading branch information
sivakumar subraani committed Jul 25, 2023
1 parent a2a5e83 commit 975f981
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
28 changes: 12 additions & 16 deletions drivers/volume/csi/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -1906,29 +1906,25 @@ func (c *csi) CleanupBackupResources(backup *storkapi.ApplicationBackup) error {
continue
}
vsMap.(map[string]*kSnapshotv1.VolumeSnapshot)[vInfo.BackupID] = snapshot
if snapshotInfo.Status == snapshotter.StatusReady {
snapshotContent, ok := snapshotInfo.Content.(*kSnapshotv1.VolumeSnapshotContent)
if !ok {
logrus.Warnf("failed to map volumesnapshotcontent object")
continue
}
vsContentMap.(map[string]*kSnapshotv1.VolumeSnapshotContent)[vInfo.BackupID] = snapshotContent
snapshotContent, ok := snapshotInfo.Content.(*kSnapshotv1.VolumeSnapshotContent)
if !ok {
logrus.Warnf("failed to map volumesnapshotcontent object")
continue
}
vsContentMap.(map[string]*kSnapshotv1.VolumeSnapshotContent)[vInfo.BackupID] = snapshotContent
} else {
snapshot, ok := snapshotInfo.SnapshotRequest.(*kSnapshotv1beta1.VolumeSnapshot)
if !ok {
logrus.Warnf("failed to map volumesnapshot object")
continue
}
vsMap.(map[string]*kSnapshotv1beta1.VolumeSnapshot)[vInfo.BackupID] = snapshot
if snapshotInfo.Status == snapshotter.StatusReady {
snapshotContent, ok := snapshotInfo.Content.(*kSnapshotv1beta1.VolumeSnapshotContent)
if !ok {
logrus.Warnf("failed to map volumesnapshotcontent object")
continue
}
vsContentMap.(map[string]*kSnapshotv1beta1.VolumeSnapshotContent)[vInfo.BackupID] = snapshotContent
snapshotContent, ok := snapshotInfo.Content.(*kSnapshotv1beta1.VolumeSnapshotContent)
if !ok {
logrus.Warnf("failed to map volumesnapshotcontent object")
continue
}
vsContentMap.(map[string]*kSnapshotv1beta1.VolumeSnapshotContent)[vInfo.BackupID] = snapshotContent
}
}
// cleanup after a successful object upload
Expand All @@ -1937,9 +1933,9 @@ func (c *csi) CleanupBackupResources(backup *storkapi.ApplicationBackup) error {
logrus.Tracef("failed to cleanup snapshots: %v", err)
}
if c.v1SnapshotRequired {
log.ApplicationBackupLog(backup).Tracef("started clean up of %v snapshots and %v snapshotcontents", len(vsMap.(map[string]*kSnapshotv1.VolumeSnapshot)), len(vsContentMap.(map[string]*kSnapshotv1.VolumeSnapshotContent)))
log.ApplicationBackupLog(backup).Infof("started clean up of %v snapshots and %v snapshotcontents", len(vsMap.(map[string]*kSnapshotv1.VolumeSnapshot)), len(vsContentMap.(map[string]*kSnapshotv1.VolumeSnapshotContent)))
} else {
log.ApplicationBackupLog(backup).Tracef("started clean up of %v snapshots and %v snapshotcontents", len(vsMap.(map[string]*kSnapshotv1beta1.VolumeSnapshot)), len(vsContentMap.(map[string]*kSnapshotv1beta1.VolumeSnapshotContent)))
log.ApplicationBackupLog(backup).Infof("started clean up of %v snapshots and %v snapshotcontents", len(vsMap.(map[string]*kSnapshotv1beta1.VolumeSnapshot)), len(vsContentMap.(map[string]*kSnapshotv1beta1.VolumeSnapshotContent)))
}
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/snapshotter/snapshotter_csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ func (c *csiDriver) SnapshotStatus(name, namespace string) (SnapshotInfo, error)
var snapshotContent *kSnapshotv1.VolumeSnapshotContent
var volumeSnapshotContentReady bool
var contentName string
if volumeSnapshotReady && snapshot.Status.BoundVolumeSnapshotContentName != nil {
if snapshot.Status.BoundVolumeSnapshotContentName != nil {
snapshotContentName := *snapshot.Status.BoundVolumeSnapshotContentName
snapshotContent, err = c.snapshotClient.SnapshotV1().VolumeSnapshotContents().Get(context.TODO(), snapshotContentName, metav1.GetOptions{})
if err != nil {
Expand Down Expand Up @@ -474,7 +474,7 @@ func (c *csiDriver) SnapshotStatus(name, namespace string) (SnapshotInfo, error)
var snapshotContent *kSnapshotv1beta1.VolumeSnapshotContent
var volumeSnapshotContentReady bool
var contentName string
if volumeSnapshotReady && snapshot.Status.BoundVolumeSnapshotContentName != nil {
if snapshot.Status.BoundVolumeSnapshotContentName != nil {
snapshotContentName := *snapshot.Status.BoundVolumeSnapshotContentName
snapshotContent, err = c.snapshotClient.SnapshotV1beta1().VolumeSnapshotContents().Get(context.TODO(), snapshotContentName, metav1.GetOptions{})
if err != nil {
Expand Down

0 comments on commit 975f981

Please sign in to comment.