Skip to content

Commit

Permalink
feat(v2): update final progress after device is closed
Browse files Browse the repository at this point in the history
longhorn/longhorn-6613

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
  • Loading branch information
c3y1huang committed Aug 23, 2024
1 parent 35bb6c4 commit ab61bf1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions deltablock.go
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,14 @@ func RestoreDeltaBlockBackupIncrementally(ctx context.Context, config *DeltaRest
return err
}
go func() {
var err error
finalProgress := 0

defer func() {
_ = deltaOps.CloseVolumeDev(volDev)

deltaOps.UpdateRestoreStatus(volDevName, finalProgress, err)

if unlockErr := lock.Unlock(); unlockErr != nil {
logrus.WithError(unlockErr).Warn("Failed to unlock")
}
Expand All @@ -948,18 +954,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)
if err := volDev.Truncate(vol.Size); err != nil {
deltaOps.UpdateRestoreStatus(volDevName, 0, err)
err = volDev.Truncate(vol.Size)
if err != nil {
return
}
}

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

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

0 comments on commit ab61bf1

Please sign in to comment.