Skip to content

Commit

Permalink
do not signal failure to hooks if Borg only reports warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Dec 10, 2021
1 parent 07f2dd7 commit 8842199
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doc/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Latest development release
| Version: 1.28.0
| Released: 2021-11-06
- Do not signal failure to hooks if Borg only emits a warning.


1.28 (2021-11-06)
-----------------
Expand Down
9 changes: 6 additions & 3 deletions emborg/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ def signal_start(self):
raise Error(f'{self.NAME} connection error.', codicil=full_stop(e))

def signal_end(self, borg):
status = borg.status
if status:
# Borg returns 0 on clear success, 1 if there was a warning, and 2 or
# greater if there was an error that prevented normal termination.
if borg.status > 1:
url = self.FAIL_URL.format(url=self.url, uuid=self.uuid)
result = 'failure'
else:
Expand Down Expand Up @@ -95,7 +96,9 @@ def signal_start(self):

def signal_end(self, borg):
status = borg.status
result = 'failure' if status else 'success'
# Borg returns 0 on clear success, 1 if there was a warning, and 2 or
# greater if there was an error that prevented normal termination.
result = 'failure' if status > 1 else 'success'
payload = borg.stderr
url = f'{self.url}/{self.uuid}/{status}'
log(f'signaling {result} of backups to {self.NAME}: {url}.')
Expand Down

0 comments on commit 8842199

Please sign in to comment.