From 74ffa50bb4b151407fa30631967307a664783be9 Mon Sep 17 00:00:00 2001 From: Ming Qiu Date: Thu, 14 Mar 2024 07:05:15 +0000 Subject: [PATCH] Fix DataDownload fails during restore for empty PVC workload Signed-off-by: Ming Qiu --- changelogs/unreleased/7521-qiuming-best | 2 ++ pkg/uploader/kopia/snapshot.go | 10 ---------- pkg/uploader/kopia/snapshot_test.go | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) create mode 100644 changelogs/unreleased/7521-qiuming-best diff --git a/changelogs/unreleased/7521-qiuming-best b/changelogs/unreleased/7521-qiuming-best new file mode 100644 index 0000000000..4e25106492 --- /dev/null +++ b/changelogs/unreleased/7521-qiuming-best @@ -0,0 +1,2 @@ +Fix DataDownload fails during restore for empty PVC workload + diff --git a/pkg/uploader/kopia/snapshot.go b/pkg/uploader/kopia/snapshot.go index 1a09562566..4a2b41c1ae 100644 --- a/pkg/uploader/kopia/snapshot.go +++ b/pkg/uploader/kopia/snapshot.go @@ -156,16 +156,6 @@ func Backup(ctx context.Context, fsUploader SnapshotUploader, repoWriter repo.Re return nil, false, errors.Wrapf(err, "Invalid source path '%s'", sourcePath) } - if volMode == uploader.PersistentVolumeFilesystem { - // to be consistent with restic when backup empty dir returns one error for upper logic handle - dirs, err := os.ReadDir(source) - if err != nil { - return nil, false, errors.Wrapf(err, "Unable to read dir in path %s", source) - } else if len(dirs) == 0 { - return nil, true, nil - } - } - source = filepath.Clean(source) sourceInfo := snapshot.SourceInfo{ diff --git a/pkg/uploader/kopia/snapshot_test.go b/pkg/uploader/kopia/snapshot_test.go index c6b634e6b9..3021389fba 100644 --- a/pkg/uploader/kopia/snapshot_test.go +++ b/pkg/uploader/kopia/snapshot_test.go @@ -610,7 +610,7 @@ func TestBackup(t *testing.T) { name: "Unable to read directory", sourcePath: "/invalid/path", tags: nil, - expectedError: errors.New("Unable to read dir"), + expectedError: errors.New("no such file or directory"), }, { name: "Source path is not a block device",