From b6d41ab88fb89e9399922a1d28d575f59a3cd947 Mon Sep 17 00:00:00 2001 From: Ruben Jenster Date: Thu, 24 Aug 2023 17:36:46 +0000 Subject: [PATCH] restic: do not log exit code when snapshot is empty Restic exit's with exit code 1 when the target directory is empty. This is not an error condition and the exit code should not be logged in this case. Signed-off-by: Ruben Jenster --- pkg/restic/exec_commands.go | 2 -- pkg/uploader/provider/restic.go | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/restic/exec_commands.go b/pkg/restic/exec_commands.go index 94c17c04a4..c4cf2fb297 100644 --- a/pkg/restic/exec_commands.go +++ b/pkg/restic/exec_commands.go @@ -86,7 +86,6 @@ func RunBackup(backupCmd *Command, log logrus.FieldLogger, updater uploader.Prog err := cmd.Start() if err != nil { - exec.LogErrorAsExitCode(err, log) return stdoutBuf.String(), stderrBuf.String(), err } @@ -120,7 +119,6 @@ func RunBackup(backupCmd *Command, log logrus.FieldLogger, updater uploader.Prog err = cmd.Wait() if err != nil { - exec.LogErrorAsExitCode(err, log) return stdoutBuf.String(), stderrBuf.String(), err } quit <- struct{}{} diff --git a/pkg/uploader/provider/restic.go b/pkg/uploader/provider/restic.go index 6c6cf5992c..f92cca72f8 100644 --- a/pkg/uploader/provider/restic.go +++ b/pkg/uploader/provider/restic.go @@ -30,6 +30,7 @@ import ( velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1" "github.com/vmware-tanzu/velero/pkg/restic" "github.com/vmware-tanzu/velero/pkg/uploader" + "github.com/vmware-tanzu/velero/pkg/util/exec" "github.com/vmware-tanzu/velero/pkg/util/filesystem" ) @@ -161,6 +162,7 @@ func (rp *resticProvider) RunBackup( log.Debugf("Restic backup got empty dir with %s path", path) return "", true, nil } + exec.LogErrorAsExitCode(err, log) return "", false, errors.WithStack(fmt.Errorf("error running restic backup command %s with error: %v stderr: %v", backupCmd.String(), err, stderrBuf)) } // GetSnapshotID