Borgmatic sends Healthchecks.io OK ping even when there was an error #1065
Labels
No labels
blocked
breaking
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No milestone
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
borgmatic-collective/borgmatic#1065
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
I'm using the configuration in #525 to only have a ping sent to Healthchecks.io when my backup operations have succeeded, for similar reasons as the ones described in that issue (want to only be alerted if backups are persistently down, not just having a transient error).
Steps to reproduce
Actual behavior
Here's the output from the command:
The real smoking gun for me is this though:
Why is Borgmatic sending an OK ping with a fatal error message in the body?
Expected behavior
I want an OK ping to be sent when there are no errors. Otherwise, I want nothing to be sent, or at the very least, a failure ping should be sent instead of an OK ping - the behavior of sending an OK ping unconditionally effectively means that alerting is silently disabled.
Other notes / implementation ideas
No response
borgmatic version
2.0.2
borgmatic installation method
pip install
Borg version
1.2.8
Python version
3.12.3
Database version (if applicable)
No response
Operating system and version
Ubuntu 24.04.2 LTS
Looking at the code here and here it looks like my expected behavior is the intention of the code, but for some reason the error visible in the Borgmatic logs is not getting passed to
Monitoring_hooks.__exit__and thus Borgmatic does not realize there is an error here.Okay, the bug is easy to understand: the exception is caught by this code fully inside of the context manager, thus the context manager doesn't get the exception passed to it. Should be a simple refactor to fix. Also maybe worth adding a test to ensure this doesn't regress in the future? Having the backup monitoring silently disabled is a really scary failure condition.
Borgmatic sends Healthchecks.io ping even when there was an errorto Borgmatic sends Healthchecks.io OK ping even when there was an errorThanks for filing this! I think I might see the problem in code: There is logic that sends a failure ping instead of a OK ping if an error is encountered—but the error is getting swallowed by some other code before it ever makes its way to that logic. I'm not sure of the solution if that's the case, but first I'll start by seeing if I can repro the behavior you're seeing.
Oh, hah, just saw your comments. Look like you figured it out first! And yes, I agree that: 1. A refactor might fix this, and 2. Absolutely a regression test would be a good idea.
This is fixed in main and will be part of the next release. The solution I went with was re-raising the exception after all repositories had a chance to run, so that one repository erroring doesn't interfere with other repositories running. And there's a regression test as well.
Thanks again!
Released in borgmatic 2.0.3!