Skip to content

Commit

Permalink
Fix error handling to error loudly when Borg gets killed due to runni…
Browse files Browse the repository at this point in the history
…ng out of memory (#423)!
  • Loading branch information
witten committed Jun 8, 2021
1 parent f5c61c8 commit 9fd28d2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* #390: Add link to Hetzner storage offering from the documentation.
* #398: Clarify canonical home of borgmatic in documentation.
* #406: Clarify that spaces in path names should not be backslashed in path names.
* #423: Fix error handling to error loudly when Borg gets killed due to running out of memory!
* Fix build so as not to attempt to build and push documentation for a non-master branch.
* "Fix" build failure with Alpine Edge by switching from Edge to Alpine 3.13.
* Move #borgmatic IRC channel from Freenode to Libera Chat due to Freenode takeover drama.
Expand Down
2 changes: 1 addition & 1 deletion borgmatic/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def exit_code_indicates_error(process, exit_code, borg_local_path=None):
command = process.args.split(' ') if isinstance(process.args, str) else process.args

if borg_local_path and command[0] == borg_local_path:
return bool(exit_code >= BORG_ERROR_EXIT_CODE)
return bool(exit_code < 0 or exit_code >= BORG_ERROR_EXIT_CODE)

return bool(exit_code != 0)

Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
(flexmock(args=['grep']), 0, 'borg', False),
(flexmock(args=['borg']), 0, 'borg', False),
(flexmock(args=['borg1']), 0, 'borg1', False),
# -9 exit code occurs when child process get SIGKILLed.
(flexmock(args=['grep']), -9, None, True),
(flexmock(args=['grep']), -9, 'borg', True),
(flexmock(args=['borg']), -9, 'borg', True),
(flexmock(args=['borg1']), -9, 'borg1', True),
(flexmock(args=['borg']), None, None, False),
),
)
Expand Down

0 comments on commit 9fd28d2

Please sign in to comment.