From 273f4ec0c1fdc26a82a99633118731acf9fa995d Mon Sep 17 00:00:00 2001 From: Chin-Ya Huang Date: Wed, 31 Jul 2024 11:20:59 +0800 Subject: [PATCH] chore: update vendor longhorn/longhorn-6613 Signed-off-by: Chin-Ya Huang --- go.mod | 4 ++- go.sum | 8 +++--- .../longhorn/backupstore/deltablock.go | 27 ++++++++++--------- vendor/modules.txt | 5 ++-- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/go.mod b/go.mod index 01255486..cf9e5944 100644 --- a/go.mod +++ b/go.mod @@ -4,12 +4,14 @@ go 1.22.0 toolchain go1.22.5 +replace github.com/longhorn/backupstore => github.com/c3y1huang/backupstore v0.0.0-20240809014845-7e34647347fa + require ( github.com/0xPolygon/polygon-edge v1.3.3 github.com/RoaringBitmap/roaring v1.9.4 github.com/google/uuid v1.6.0 github.com/longhorn/backupstore v0.0.0-20240720163059-56c90cd23634 - github.com/longhorn/go-common-libs v0.0.0-20240727052403-b543ea3732fe + github.com/longhorn/go-common-libs v0.0.0-20240729132251-9e1e0e6045c6 github.com/longhorn/go-spdk-helper v0.0.0-20240727080828-a55a2982815a github.com/longhorn/types v0.0.0-20240725040629-473d671316c4 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index f65b496b..d534aed2 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.12.0 h1:U/q1fAF7xXRhFCrhROzIfffYnu+dlS38vCZtmFVPHmA= github.com/bits-and-blooms/bitset v1.12.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/c3y1huang/backupstore v0.0.0-20240809014845-7e34647347fa h1:xEiu8wcITNPIb9YQoi3Znx/VmPBelEq5bzcWmG3q/HI= +github.com/c3y1huang/backupstore v0.0.0-20240809014845-7e34647347fa/go.mod h1:3LS9oGrEAUO59xbdACCbKlr7j9LkAvmx8RCJBCfnTaE= github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8 h1:SjZ2GvvOononHOpK84APFuMvxqsk3tEIaKH/z4Rpu3g= github.com/c9s/goprocinfo v0.0.0-20210130143923-c95fcf8c64a8/go.mod h1:uEyr4WpAH4hio6LFriaPkL938XnrvLpNPmQHBdrmbIE= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= @@ -37,10 +39,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/longhorn/backupstore v0.0.0-20240720163059-56c90cd23634 h1:gfrFl0YwZSfyiaLdg7TFKSHtBgMJclDGDtBjUhGe0ik= -github.com/longhorn/backupstore v0.0.0-20240720163059-56c90cd23634/go.mod h1:7L/qcMq6IK3S/VU52AtmeKCnOK9Tz1XmMilzo2ILEm8= -github.com/longhorn/go-common-libs v0.0.0-20240727052403-b543ea3732fe h1:EiCGiOecnzl4dp0nDesT6UD6wA7T44VnUiXxYYdVBG0= -github.com/longhorn/go-common-libs v0.0.0-20240727052403-b543ea3732fe/go.mod h1:n8qac+ubzVdubf0kuMzsjKZxn43IuhLAHeakwpnB7UM= +github.com/longhorn/go-common-libs v0.0.0-20240729132251-9e1e0e6045c6 h1:RysSv4aS6oZD1w3tqVIyisAmHDYn/oo30x2ACNVLI5w= +github.com/longhorn/go-common-libs v0.0.0-20240729132251-9e1e0e6045c6/go.mod h1:n8qac+ubzVdubf0kuMzsjKZxn43IuhLAHeakwpnB7UM= github.com/longhorn/go-spdk-helper v0.0.0-20240727080828-a55a2982815a h1:x54NTKwvpdpfeVHPEcZ3XNxFHVb4qAKRHCaUFHwbriU= github.com/longhorn/go-spdk-helper v0.0.0-20240727080828-a55a2982815a/go.mod h1:sD6aVynQSbPnYyJ77NLiYbWNI5zyzxcVzIEnXFcKCww= github.com/longhorn/nsfilelock v0.0.0-20200723175406-fa7c83ad0003 h1:Jw9uANsGcHTxp6HcC++/vN17LfeuDmozHI2j6DoZf5E= diff --git a/vendor/github.com/longhorn/backupstore/deltablock.go b/vendor/github.com/longhorn/backupstore/deltablock.go index 16c5ad42..63864b18 100644 --- a/vendor/github.com/longhorn/backupstore/deltablock.go +++ b/vendor/github.com/longhorn/backupstore/deltablock.go @@ -110,7 +110,7 @@ type DeltaBlockBackupOperations interface { } type DeltaRestoreOperations interface { - OpenVolumeDev(volDevName string) (*os.File, string, error) + OpenVolumeDev(volDevName string, dmDeviceAndEndpointCleanupRequired bool) (*os.File, string, error) CloseVolumeDev(volDev *os.File) error UpdateRestoreStatus(snapshot string, restoreProgress int, err error) Stop() @@ -735,7 +735,7 @@ func RestoreDeltaBlockBackup(ctx context.Context, config *DeltaRestoreConfig) er return fmt.Errorf("invalid volume size %v", vol.Size) } - volDev, volDevPath, err := deltaOps.OpenVolumeDev(volDevName) + volDev, volDevPath, err := deltaOps.OpenVolumeDev(volDevName, false) if err != nil { return errors.Wrapf(err, "failed to open volume device %v", volDevName) } @@ -843,8 +843,9 @@ func RestoreDeltaBlockBackupIncrementally(ctx context.Context, config *DeltaRest lastBackupName := config.LastBackupName deltaOps := config.DeltaOps if deltaOps == nil { - return fmt.Errorf("missing DeltaBlockBackupOperations") + return fmt.Errorf("missing DeltaRestoreOperations") } + bsDriver, err := GetBackupStoreDriver(backupURL) if err != nil { return err @@ -894,14 +895,14 @@ func RestoreDeltaBlockBackupIncrementally(ctx context.Context, config *DeltaRest } } - volDev, err := os.Create(volDevName) + volDev, volDevPath, err := deltaOps.OpenVolumeDev(volDevName, true) if err != nil { - return err + return errors.Wrapf(err, "failed to open volume device %v", volDevName) } defer func() { // make sure to close the device if err != nil { - _ = volDev.Close() + _ = deltaOps.CloseVolumeDev(volDev) } }() @@ -933,10 +934,10 @@ func RestoreDeltaBlockBackupIncrementally(ctx context.Context, config *DeltaRest return err } go func() { - defer volDev.Close() defer func() { + _ = deltaOps.CloseVolumeDev(volDev) if unlockErr := lock.Unlock(); unlockErr != nil { - logrus.WithError(err).Warn("Failed to unlock") + logrus.WithError(unlockErr).Warn("Failed to unlock") } }() @@ -945,15 +946,15 @@ func RestoreDeltaBlockBackupIncrementally(ctx context.Context, config *DeltaRest // closed. // https://github.com/longhorn/longhorn/issues/2503 // We want to truncate regular files, but not device - if stat.Mode()&os.ModeType == 0 { - log.Debugf("Truncate %v to size %v", volDevName, vol.Size) + 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) return } } - if err := performIncrementalRestore(ctx, bsDriver, config, srcVolumeName, volDevName, lastBackup, backup); err != nil { + if err := performIncrementalRestore(ctx, bsDriver, config, srcVolumeName, volDevPath, lastBackup, backup); err != nil { deltaOps.UpdateRestoreStatus(volDevName, 0, err) return } @@ -1107,7 +1108,7 @@ func restoreBlocks(ctx context.Context, bsDriver BackupStoreDriver, deltaOps Del } func performIncrementalRestore(ctx context.Context, bsDriver BackupStoreDriver, config *DeltaRestoreConfig, - srcVolumeName, volDevName string, lastBackup *Backup, backup *Backup) error { + srcVolumeName, volDevPath string, lastBackup *Backup, backup *Backup) error { var err error concurrentLimit := config.ConcurrentLimit @@ -1119,7 +1120,7 @@ func performIncrementalRestore(ctx context.Context, bsDriver BackupStoreDriver, errorChans := []<-chan error{errChan} for i := 0; i < int(concurrentLimit); i++ { - errorChans = append(errorChans, restoreBlocks(ctx, bsDriver, config.DeltaOps, config.Filename, srcVolumeName, blockChan, progress)) + errorChans = append(errorChans, restoreBlocks(ctx, bsDriver, config.DeltaOps, volDevPath, srcVolumeName, blockChan, progress)) } mergedErrChan := mergeErrorChannels(ctx, errorChans...) diff --git a/vendor/modules.txt b/vendor/modules.txt index 39584f05..59b71aac 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -39,13 +39,13 @@ github.com/kr/pretty # github.com/kr/text v0.2.0 ## explicit github.com/kr/text -# github.com/longhorn/backupstore v0.0.0-20240720163059-56c90cd23634 +# github.com/longhorn/backupstore v0.0.0-20240720163059-56c90cd23634 => github.com/c3y1huang/backupstore v0.0.0-20240809014845-7e34647347fa ## explicit; go 1.22.0 github.com/longhorn/backupstore github.com/longhorn/backupstore/logging github.com/longhorn/backupstore/types github.com/longhorn/backupstore/util -# github.com/longhorn/go-common-libs v0.0.0-20240727052403-b543ea3732fe +# github.com/longhorn/go-common-libs v0.0.0-20240729132251-9e1e0e6045c6 ## explicit; go 1.22.0 github.com/longhorn/go-common-libs/backup github.com/longhorn/go-common-libs/exec @@ -287,3 +287,4 @@ k8s.io/utils/internal/third_party/forked/golang/net k8s.io/utils/io k8s.io/utils/keymutex k8s.io/utils/net +# github.com/longhorn/backupstore => github.com/c3y1huang/backupstore v0.0.0-20240809014845-7e34647347fa