2
0
Эх сурвалжийг харах

Fix error handling to error loudly when Borg gets killed due to running out of memory (#423)!

Dan Helfman 4 жил өмнө
parent
commit
9fd28d2eed

+ 1 - 0
NEWS

@@ -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.

+ 1 - 1
borgmatic/execute.py

@@ -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)
 

+ 5 - 0
tests/unit/test_execute.py

@@ -21,6 +21,11 @@ from borgmatic import execute as module
         (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),
     ),
 )