Skip to content
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

pb-4093 Deleting the volumesnapshotcontent in the case of failed native CSI backup. #1460

Merged
merged 1 commit into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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