Skip to content

Commit

Permalink
fix(backup): delete the snapshot directly by backup.Spec.SnapshotName
Browse files Browse the repository at this point in the history
Delete the snapshot directly by `backup.Spec.SnapshotName` when doing
the automatic cleanup by deleting the backup.

ref: longhorn/longhorn 9252

Signed-off-by: James Lu <james.lu@suse.com>
  • Loading branch information
mantissahz authored and mergify[bot] committed Aug 19, 2024
1 parent 5c07281 commit 19ba220
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions controller/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,10 @@ func (bc *BackupController) reconcile(backupName string) (err error) {
}
if autocleanup {
// do the best effort to delete the snapshot
snapshot, err := bc.ds.GetSnapshotRO(backup.Spec.SnapshotName)
if err != nil {
if !apierrors.IsNotFound(err) {
logrus.WithError(err).WithFields(logrus.Fields{
"backup": backup.Name,
"snapshot": snapshot.Name,
}).Warn("Failed to get snapshot")
}
return nil
}
if err = bc.ds.DeleteSnapshot(snapshot.Name); err != nil {
if err = bc.ds.DeleteSnapshot(backup.Spec.SnapshotName); err != nil {
logrus.WithError(err).WithFields(logrus.Fields{
"backup": backup.Name,
"snapshot": snapshot.Name,
"snapshot": backup.Spec.SnapshotName,
}).Warn("Failed to delete snapshot")
}
}
Expand Down

0 comments on commit 19ba220

Please sign in to comment.