Give the backup unit network access so its heartbeat ping can leave #24

Merged
patrick merged 1 commits from fix/backup-heartbeat-network into main 2026-10-31 19:04:21 +00:00
Owner

Problem

The backup heartbeat check on healthchecks.io went down a day after setup, even though the nightly backups were succeeding.

kernelwatch-backup.service still had PrivateNetwork=yes and RestrictAddressFamilies=AF_UNIX. Those settings date from before scheduled-backup started pinging backup_heartbeat_url. Inside that sandbox DNS can't resolve, so every ping failed:

kernelwatch: heartbeat request failed (URLError)

ping() logs the failure on purpose and doesn't fail the run. So the backup still counted as successful, and the only visible symptom was the monitor going quiet. Running kernelwatch test-heartbeat outside the sandbox showed both URLs worked.

Changes

  • server/kernelwatch-backup.service: drop PrivateNetwork=yes and allow AF_INET/AF_INET6, the same as kernelwatch-alerts.service. The rest of the sandbox stays as it was.
  • tests/test_install.py: new test_units_that_send_requests_have_network_access. Every unit that runs check-alerts, scheduled-backup or notify-backup-failure must keep IP network access: no PrivateNetwork=, no IPAddressDeny=, and RestrictAddressFamilies= must include AF_INET and AF_INET6. The test fails on the old unit.
  • docs/security.md: a note that the server's timer units need outbound network access (ntfy and the heartbeats).

Testing

  • make test: all 242 tests pass.
  • The new test fails against the previous backup unit.

Deploying

Re-run server/install.sh, which copies the units and runs daemon-reload. If you added a systemctl edit override as a stopgap, remove it after upgrading with sudo systemctl revert kernelwatch-backup.service, then sudo systemctl daemon-reload. To confirm, run sudo systemctl start kernelwatch-backup.service; the backup check on healthchecks.io should go back to up.

🤖 Generated with Claude Code

## Problem The backup heartbeat check on healthchecks.io went down a day after setup, even though the nightly backups were succeeding. `kernelwatch-backup.service` still had `PrivateNetwork=yes` and `RestrictAddressFamilies=AF_UNIX`. Those settings date from before `scheduled-backup` started pinging `backup_heartbeat_url`. Inside that sandbox DNS can't resolve, so every ping failed: kernelwatch: heartbeat request failed (URLError) `ping()` logs the failure on purpose and doesn't fail the run. So the backup still counted as successful, and the only visible symptom was the monitor going quiet. Running `kernelwatch test-heartbeat` outside the sandbox showed both URLs worked. ## Changes - **`server/kernelwatch-backup.service`**: drop `PrivateNetwork=yes` and allow `AF_INET`/`AF_INET6`, the same as `kernelwatch-alerts.service`. The rest of the sandbox stays as it was. - **`tests/test_install.py`**: new `test_units_that_send_requests_have_network_access`. Every unit that runs `check-alerts`, `scheduled-backup` or `notify-backup-failure` must keep IP network access: no `PrivateNetwork=`, no `IPAddressDeny=`, and `RestrictAddressFamilies=` must include `AF_INET` and `AF_INET6`. The test fails on the old unit. - **`docs/security.md`**: a note that the server's timer units need outbound network access (ntfy and the heartbeats). ## Testing - `make test`: all 242 tests pass. - The new test fails against the previous backup unit. ## Deploying Re-run `server/install.sh`, which copies the units and runs `daemon-reload`. If you added a `systemctl edit` override as a stopgap, remove it after upgrading with `sudo systemctl revert kernelwatch-backup.service`, then `sudo systemctl daemon-reload`. To confirm, run `sudo systemctl start kernelwatch-backup.service`; the backup check on healthchecks.io should go back to up. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
patrick added 1 commit 2026-10-31 19:00:27 +00:00
Give the backup unit network access so its heartbeat ping can leave
CI / tests (Python 3.11) (pull_request) Successful in 28s
CI / tests (Python 3.10) (pull_request) Successful in 29s
CI / tests (Python 3.12) (pull_request) Successful in 25s
CI / tests (Python 3.13) (pull_request) Successful in 26s
CI / lint (pull_request) Successful in 2s
f9d9660f71
kernelwatch-backup.service still had PrivateNetwork=yes and
RestrictAddressFamilies=AF_UNIX from before scheduled-backup pinged
backup_heartbeat_url. Every nightly ping failed DNS inside the sandbox
("heartbeat request failed (URLError)"); the backup itself succeeded, so
the only symptom was the heartbeat monitor going down after a day.

Allow AF_INET/AF_INET6 like the alerts unit, and add a test that every
unit running a command that sends requests (check-alerts,
scheduled-backup, notify-backup-failure) keeps network access.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
patrick merged commit 3e2f550414 into main 2026-10-31 19:04:21 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: patrick/kernel-automation#24