Skip to content

Commit

Permalink
fix: log error when failed to close volume device
Browse files Browse the repository at this point in the history
Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
  • Loading branch information
c3y1huang authored and derekbit committed Aug 27, 2024
1 parent d330ae2 commit fe89e48
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions deltablock.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,9 @@ func RestoreDeltaBlockBackup(ctx context.Context, config *DeltaRestoreConfig) er
}
defer func() {
if err != nil {
_ = deltaOps.CloseVolumeDev(volDev)
if _err := deltaOps.CloseVolumeDev(volDev); _err != nil {
logrus.WithError(_err).Warnf("Failed to close volume device %v", volDevName)
}
}
}()

Expand Down Expand Up @@ -775,7 +777,10 @@ func RestoreDeltaBlockBackup(ctx context.Context, config *DeltaRestoreConfig) er
currentProgress := 0

defer func() {
_ = deltaOps.CloseVolumeDev(volDev)
if _err := deltaOps.CloseVolumeDev(volDev); _err != nil {
logrus.WithError(_err).Warnf("Failed to close volume device %v", volDevName)
}

deltaOps.UpdateRestoreStatus(volDevName, currentProgress, err)
if unlockErr := lock.Unlock(); unlockErr != nil {
logrus.WithError(unlockErr).Warn("Failed to unlock")
Expand Down Expand Up @@ -902,7 +907,9 @@ func RestoreDeltaBlockBackupIncrementally(ctx context.Context, config *DeltaRest
defer func() {
// make sure to close the device
if err != nil {
_ = deltaOps.CloseVolumeDev(volDev)
if _err := deltaOps.CloseVolumeDev(volDev); _err != nil {
logrus.WithError(_err).Warnf("Failed to close volume device %v", volDevName)
}
}
}()

Expand Down Expand Up @@ -938,7 +945,9 @@ func RestoreDeltaBlockBackupIncrementally(ctx context.Context, config *DeltaRest
finalProgress := 0

defer func() {
_ = deltaOps.CloseVolumeDev(volDev)
if _err := deltaOps.CloseVolumeDev(volDev); _err != nil {
logrus.WithError(_err).Warnf("Failed to close volume device %v", volDevName)
}

deltaOps.UpdateRestoreStatus(volDevName, finalProgress, err)

Expand Down

0 comments on commit fe89e48

Please sign in to comment.