feat(decdn_node): enable the systemd watchdog on the node unit - #78
Merged
Merged
Conversation
decdn-node heartbeats WATCHDOG=1 from its tokio runtime when the unit sets WatchdogSec (decdn/decdn#2145). A node whose runtime workers are all held by work that never yields stops the heartbeat, and systemd restarts it instead of leaving it `active` while it serves nothing. - WatchdogSec={{ decdn_node_watchdog_sec }} (default 60) plus NotifyAccess=main, so systemd accepts the main PID's heartbeat. - AF_UNIX joins RestrictAddressFamilies, since the heartbeat goes over NOTIFY_SOCKET. - decdn_node_watchdog_sec: 0 omits all three, for a binary that predates the heartbeat and would otherwise be killed every period. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The new watchdog is enabled by default (60s) despite being incompatible with older decdn-node binaries, which can cause immediate restart loops unless users proactively override it.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
This PR enables systemd watchdog support for the decdn-node systemd unit rendered by the decdn_node Ansible role, so systemd can restart the node when it becomes runtime-stalled (e.g., tokio workers stop yielding) but the process remains alive.
Changes:
- Add conditional
WatchdogSec=+NotifyAccess=mainto the node unit whendecdn_node_watchdog_sec > 0. - Extend
RestrictAddressFamilies=to conditionally allowAF_UNIXwhen watchdog is enabled (forNOTIFY_SOCKET). - Introduce
decdn_node_watchdog_secrole default (currently set to60) with documentation about disabling it for older binaries.
| File | Description |
|---|---|
| ansible/roles/decdn_node/templates/decdn-node.service.j2 | Conditionally enables systemd watchdog directives and allows AF_UNIX only when needed. |
| ansible/roles/decdn_node/defaults/main.yml | Adds a new default variable controlling watchdog behavior and documents the version dependency. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The role cannot tell whether the binary it installs heartbeats, and a binary that does not is killed every period, so decdn_node_watchdog_sec defaults to 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
When every tokio worker in
decdn-nodeis held by work that never yields, the node serves nothing, logs nothing and answers no/metricsscrape. The process keeps running, though, so the unit staysactivewithRestart=alwaysnever firing.Fix
decdn/decdn#2145 makes the node send
WATCHDOG=1from a task on its runtime when the unit setsWatchdogSec=. This PR turns that on in the role:WatchdogSec={{ decdn_node_watchdog_sec }}andNotifyAccess=main, rendered whendecdn_node_watchdog_sec > 0. systemd kills a node that misses the deadline with SIGABRT, andRestart=alwaysbrings it back.AF_UNIXis added toRestrictAddressFamilies, because the heartbeat goes overNOTIFY_SOCKET.decdn_node_watchdog_secdefaults to0, which omits all three directives. The role cannot tell whether the binary it installs sends the heartbeat, so the watchdog is opt-in. Set it (e.g.60) once the deployed build includes feat(node): heartbeat the systemd watchdog from the runtime and test serve-loop starvation decdn#2145.Enabling it: set
decdn_node_watchdog_seconly for hosts whosedecdn-nodebuild includes decdn/decdn#2145. An older binary sends no heartbeat, so systemd would kill it every period.I checked the rendered unit with
trim_blocks=True(Ansible's default) for both60and0.🤖 Generated with Claude Code