Skip to content

Commit

Permalink
feat(restore): cleanup DM device and endpoint for v2 volume increment…
Browse files Browse the repository at this point in the history
…al restore

longhorn/longhorn-6613

Signed-off-by: Chin-Ya Huang <[email protected]>
  • Loading branch information
c3y1huang committed Aug 1, 2024
1 parent 6f78e0e commit 23f54c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions deltablock.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -894,7 +894,7 @@ func RestoreDeltaBlockBackupIncrementally(ctx context.Context, config *DeltaRest
}
}

volDev, volDevPath, err := deltaOps.OpenVolumeDev(volDevName)
volDev, volDevPath, err := deltaOps.OpenVolumeDev(volDevName, true)
if err != nil {
return errors.Wrapf(err, "failed to open volume device %v", volDevName)
}
Expand Down
2 changes: 1 addition & 1 deletion test/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type RawFileVolume struct {
stopChan chan struct{}
}

func (r *RawFileVolume) OpenVolumeDev(volDevName string) (*os.File, string, error) {
func (r *RawFileVolume) OpenVolumeDev(volDevName string, dmDeviceAndEndpointCleanupRequired bool) (*os.File, string, error) {
if _, err := os.Stat(volDevName); err == nil {
logrus.WithError(err).Warnf("File %s for the restore exists, will remove and re-create it", volDevName)
if err := os.RemoveAll(volDevName); err != nil {
Expand Down

0 comments on commit 23f54c1

Please sign in to comment.