sanoid
sanoid copied to clipboard
CRITICAL ERROR does not result in non-zero exit code
I've noticed that a CRITICAL ERROR
message can be thrown in a number of different cases, but this doesn't seem to always result in a non-zero exit code for sanoid. By "silently" failing with 0, it's hard to detect and alert about a problem or error.
Here's an example (using sanoid 2.1.0) - if you misconfigure the dataset name in sanoid.conf
to an invalid value, such as below with a trailing slash, a CRITICAL ERROR
will be thrown but sanoid will exit with 0:
sanoid.conf:
[path/to/dataset/]
frequently = 1
hourly = 1
daily = 1
weekly = 1
monthly = 1
yearly = 1
autosnap = yes
autoprune = yes
running sanoid:
# sanoid --take-snapshots --verbose ; echo $?
INFO: cache expired - updating from zfs list.
INFO: taking snapshots...
taking snapshot path/to/dataset/@autosnap_2021-08-24_09:00:01_yearly
cannot open 'path/to/dataset/': trailing slash in name
usage:
snapshot|snap [-r] [-o property=value] ... <filesystem|volume>@<snap> ...
For the property list, run: zfs set|get
For the delegated permission list, run: zfs allow|unallow
CRITICAL ERROR: zfs snapshot path/to/dataset/@autosnap_2021-08-24_09:00:01_yearly failed, 512 at /usr/local/bin/sanoid line 627.
0
Is it possible to make sanoid exit with a non-zero exit code whenever a CRITICAL ERROR
is encountered so errors can be more easily detected? Thanks!
In addition to what I described above, a situation I encounter often is when using syncoid -r
one of the child datasets will throw the following error:
cannot receive incremental stream: dataset is busy
This occurs on the "B" node in an A -> B -> C setup when syncing from A to B. Ideally, these dataset is busy
errors would return a different error code than other errors, since I want to ignore them as non-errors which will resolve themselves on a later run (e.g. when B is no longer syncing that particular dataset to C).