Support for healthchecks auto provisionning (related to #815) #852
No reviewers
Labels
No Label
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#852
Loading…
Reference in New Issue
No description provided.
Delete Branch "estebanthi/borgmatic:f/healthchecks-auto-provisionning"
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?
Thanks for implementing this—and tests too! Overall approach looks good to me, although I left some comments about the specifics of the regex used to match ping URLs.
@ -59,10 +60,15 @@ def ping_monitor(hook_config, config, config_filename, state, monitoring_log_lev
)
return
ping_url_is_uuid = re.match(r'(\w{4}-?){4}$', hook_config['ping_url'])
I don't think this regular expression is actually correct for Healthchecks' ping URLs. For instance, this doesn't match:
So maybe something like this would work better?
Note the use of
re.search()
, which can match against part of a string rather than having to match against the whole thing likere.match()
.@ -63,3 +66,4 @@
if healthchecks_state:
ping_url = f'{ping_url}/{healthchecks_state}'
if hook_config.get('create_slug') and not ping_url_is_uuid:
Do you think it's worth issuing a warning or even an error if a UUID-style URL is used with
create_slug
? Seems like a user might want to find out about the misconfiguration instead of it silently getting swallowed.48c2f2f198
to407bb33359
Thanks for your feedback! I've modified the regex, and you're right it's worth issuing a warning if using a UUID-style URL with
create_slug
, I've implemented this too.LGTM! Thanks so much for the PR and for making these updates.
@ -267,0 +316,4 @@
)
def test_ping_monitor_issues_warning_when_ping_url_is_uuid_and_create_slug_true():
IMO this test could be combined with the previous given that there setups are identical and the only assertion difference is a single log action. (Do not feel strongly.)