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

Error handling #72

Open
macropin opened this issue Feb 21, 2019 · 1 comment
Open

Error handling #72

macropin opened this issue Feb 21, 2019 · 1 comment
Milestone

Comments

@macropin
Copy link

macropin commented Feb 21, 2019

These scripts don't handle errors. Please consider set -e at the top of each script so that error conditions will be trapped. The exit 0 at the bottom of each script can also be removed as it's redundant.

Use case / justification:

We monitor btrfs-balance.service, however when an error condition is encountered the script returns with an exit code of 0 even though the balance failed: ERROR: error during balancing '/backup': No space left on device There may be more info in syslog - try dmesg | tail

@kdave
Copy link
Owner

kdave commented Nov 6, 2019

The exit 0 overriedes the last exit code, which is call to the logging facility (systemd-cat, cat, logger), so I'm not sure this is what your monitoring is interested in. Catching the error code of the previous comand group (calling btrfs) can be extracted from PIPESTATUS though.

Adding set -e makes sense, though not all errors are fatal. The balance tries to make the space more compact but may not succeed. But this is the message you posted as an example so I guess you want to see that anyway.

@kdave kdave added this to the v0.4.3 milestone Nov 6, 2019
@kdave kdave modified the milestones: v0.4.3, v0.5.1 Jul 30, 2020
@kdave kdave modified the milestones: v0.5.1, v0.5.2 Jul 21, 2021
@kdave kdave modified the milestones: v0.5.2, v0.5.3 Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants