Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restic: do not log exit code when snapshot is empty #6699

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

r10r
Copy link

@r10r r10r commented Aug 24, 2023

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.

Please add a summary of your change

It really confused me to see the following error in the output when updating to v1.12.0-rc.1

time="2023-08-24T17:12:28Z" level=error msg="Restic command fail with ExitCode: 1. Process ID is 26, Exit error is: exit status 1" backup=velero2/gitea-backup-6 controller=podvolumebackup logSource="pkg/util/exec/exec.go:66" parentSnapshot= path="/host_pods/4d7c854f-9d1e-4ff0-a594-26ca68d3d2df/volumes/kubernetes.io~empty-dir/tmp" podvolumebackup=velero2/gitea-backup-6-5wnhb
time="2023-08-24T17:12:28Z" level=debug msg="Restic backup got empty dir with /host_pods/4d7c854f-9d1e-4ff0-a594-26ca68d3d2df/volumes/kubernetes.io~empty-dir/tmp path" backup=velero2/gitea-backup-6 controller=podvolumebackup logSource=

Please note that the second log line is only shown when debug logging is enabled.
The change in logging was introduced with #6459

Does your change fix a particular issue?

No because I did not create one.

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • Updated the corresponding documentation in site/content/docs/main.

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 <r.jenster@drachenfels.de>
@blackpiglet blackpiglet added the kind/changelog-not-required PR does not require a user changelog. Often for docs, website, or build changes label Aug 30, 2023
@blackpiglet
Copy link
Contributor

blackpiglet commented Aug 30, 2023

@qiuming-best
Please take a look at this PR.
Is it possible to move the check earlier when the error is reported, for example in pkg/restic/exec_commands.go's function RunBackup?

		if strings.Contains(stderrBuf, "snapshot is empty") {
			log.Debugf("Restic backup got empty dir with %s path", path)
			return "", true, nil
		}

@codecov
Copy link

codecov bot commented Aug 30, 2023

Codecov Report

Merging #6699 (b6d41ab) into main (4975437) will increase coverage by 0.00%.
Report is 7 commits behind head on main.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #6699   +/-   ##
=======================================
  Coverage   60.36%   60.36%           
=======================================
  Files         242      242           
  Lines       25982    25981    -1     
=======================================
+ Hits        15683    15684    +1     
+ Misses       9196     9194    -2     
  Partials     1103     1103           
Files Changed Coverage Δ
pkg/restic/exec_commands.go 15.21% <ø> (+0.16%) ⬆️
pkg/uploader/provider/restic.go 80.73% <100.00%> (+0.17%) ⬆️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/changelog-not-required PR does not require a user changelog. Often for docs, website, or build changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants