Skip to content

Commit bbf8293

Browse files
committed
add flag to treat exit code 24 like exit code 0
1 parent c9b3b92 commit bbf8293

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cmd/rsync-prom/main.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ func rsyncprommain() error {
3131
flag.StringVar(&params.Job, "job",
3232
"rsync",
3333
"prometheus job label")
34+
exit24IsExit0 := flag.Bool("exit_24_is_exit_0",
35+
false,
36+
// e.g.: directory has vanished: "/home/michael/.local/share/containers/storage/overlay/2dcb7ef2c46242b1584effa327b6faf276075d76637d508775befdef4415e2c0"
37+
"rsync exits with status code 24 when a file or directory vanishes between listing and transferring it. this can be expected (when doing a full backup while working with docker containers, for example) or cause for concern (when replicating an ever-growing data set). when this flag is enabled, rsync-prom treats exit code 24 like exit code 0 (expected)")
3438
flag.Parse()
3539

3640
ctx := context.Background()
@@ -56,7 +60,11 @@ func rsyncprommain() error {
5660
if err := rsync.Wait(); err != nil {
5761
if exiterr, ok := err.(*exec.ExitError); ok {
5862
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
59-
return status.ExitStatus()
63+
code := status.ExitStatus()
64+
if *exit24IsExit0 && code == 24 {
65+
code = 0
66+
}
67+
return code
6068
}
6169
}
6270
log.Print(err)

0 commit comments

Comments
 (0)