Skip to content

Commit

Permalink
revert: "feat(v2): update final progress after device is closed"
Browse files Browse the repository at this point in the history
This reverts commit d330ae2.

longhorn/longhorn-9305
  • Loading branch information
c3y1huang committed Aug 28, 2024
1 parent fe89e48 commit 14096a2
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions deltablock.go
Original file line number Diff line number Diff line change
Expand Up @@ -941,16 +941,10 @@ func RestoreDeltaBlockBackupIncrementally(ctx context.Context, config *DeltaRest
return err
}
go func() {
var err error
finalProgress := 0

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

deltaOps.UpdateRestoreStatus(volDevName, finalProgress, err)

if unlockErr := lock.Unlock(); unlockErr != nil {
logrus.WithError(unlockErr).Warn("Failed to unlock")
}
Expand All @@ -963,18 +957,18 @@ func RestoreDeltaBlockBackupIncrementally(ctx context.Context, config *DeltaRest
// We want to truncate regular files, but not device
if stat.Mode().IsRegular() {
log.Infof("Truncate %v to size %v", volDevName, vol.Size)
err = volDev.Truncate(vol.Size)
if err != nil {
if err := volDev.Truncate(vol.Size); err != nil {
deltaOps.UpdateRestoreStatus(volDevName, 0, err)
return
}
}

err = performIncrementalRestore(ctx, bsDriver, config, srcVolumeName, volDevPath, lastBackup, backup)
if err != nil {
if err := performIncrementalRestore(ctx, bsDriver, config, srcVolumeName, volDevPath, lastBackup, backup); err != nil {
deltaOps.UpdateRestoreStatus(volDevName, 0, err)
return
}

finalProgress = PROGRESS_PERCENTAGE_BACKUP_TOTAL
deltaOps.UpdateRestoreStatus(volDevName, PROGRESS_PERCENTAGE_BACKUP_TOTAL, nil)
}()
return nil
}
Expand Down

0 comments on commit 14096a2

Please sign in to comment.