From 806234e043251a3007d03748299a745b2af02521 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Mon, 13 Jun 2022 11:29:57 +0800 Subject: [PATCH] Add more information for failing to get path or snapshot in restic backup and restore. Signed-off-by: Xun Jiang --- changelogs/unreleased/4988-jxun | 1 + pkg/controller/pod_volume_backup_controller.go | 2 +- pkg/controller/pod_volume_restore_controller.go | 2 +- pkg/restic/exec_commands.go | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 changelogs/unreleased/4988-jxun diff --git a/changelogs/unreleased/4988-jxun b/changelogs/unreleased/4988-jxun new file mode 100644 index 000000000..204c8efb3 --- /dev/null +++ b/changelogs/unreleased/4988-jxun @@ -0,0 +1 @@ +Add more information for failing to get path or snapshot in restic backup and restore. \ No newline at end of file diff --git a/pkg/controller/pod_volume_backup_controller.go b/pkg/controller/pod_volume_backup_controller.go index b1121d5e5..322592f80 100644 --- a/pkg/controller/pod_volume_backup_controller.go +++ b/pkg/controller/pod_volume_backup_controller.go @@ -211,7 +211,7 @@ func (r *PodVolumeBackupReconciler) singlePathMatch(path string) (string, error) } if len(matches) != 1 { - return "", errors.Errorf("expected one matching path, got %d", len(matches)) + return "", errors.Errorf("expected one matching path: %s, got %d", path, len(matches)) } return matches[0], nil diff --git a/pkg/controller/pod_volume_restore_controller.go b/pkg/controller/pod_volume_restore_controller.go index 2b9cfd407..3315dae3b 100644 --- a/pkg/controller/pod_volume_restore_controller.go +++ b/pkg/controller/pod_volume_restore_controller.go @@ -222,7 +222,7 @@ func singlePathMatch(path string) (string, error) { } if len(matches) != 1 { - return "", errors.Errorf("expected one matching path, got %d", len(matches)) + return "", errors.Errorf("expected one matching path: %s, got %d", path, len(matches)) } return matches[0], nil diff --git a/pkg/restic/exec_commands.go b/pkg/restic/exec_commands.go index a0d16d8d5..7dd0057c0 100644 --- a/pkg/restic/exec_commands.go +++ b/pkg/restic/exec_commands.go @@ -63,7 +63,7 @@ func GetSnapshotID(snapshotIdCmd *Command) (string, error) { } if len(snapshots) != 1 { - return "", errors.Errorf("expected one matching snapshot, got %d", len(snapshots)) + return "", errors.Errorf("expected one matching snapshot by command: %s, got %d", snapshotIdCmd.String(), len(snapshots)) } return snapshots[0].ShortID, nil