From 5cc2e815df20a59a92b772ffba9417492170215a Mon Sep 17 00:00:00 2001 From: Chin-Ya Huang Date: Wed, 28 Aug 2024 11:46:56 +0800 Subject: [PATCH] revert: "feat(v2): update final progress after device is closed" This reverts commit d330ae2a0c264cbfe0ec2fd07984b6f3f6a9b99b. longhorn/longhorn-9305 Signed-off-by: Chin-Ya Huang --- deltablock.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/deltablock.go b/deltablock.go index edb237cd7..f6b02c1e6 100644 --- a/deltablock.go +++ b/deltablock.go @@ -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") } @@ -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 }