feat(slots): push-driven failure detector for unexpected unit deaths#8
Merged
Merged
Conversation
When a slot's systemd unit died mid-life (OOM, segfault, image-pull failure during warmup), the state machine only flipped to ERROR on the next status() poll or after _await_ready's 180s grace — leaving SSE watchers stuck on "ready" for minutes before any error frame. Add a per-slot async watcher task that polls `systemctl is-active` every 2s while the slot is in READY/SERVING/IDLE. On inactive/failed, it pushes a forced ERROR transition (broadcast over SSE) within ~1s of detection. Watcher is spawned/cancelled automatically from _transition so live-state entry/exit drives lifecycle. Tests in tests/slots/test_fail_watcher.py simulate a unit dying and assert the ERROR transition + SSE frame land within 5s, plus a clean unload cancels the watcher cleanly with no spurious ERROR push. Shared fixtures (systemctl_stub, stub_await_ready, slot_root) moved from test_manager.py to tests/slots/conftest.py so the new test file reuses them. Refs task #11. Co-Authored-By: Claude Opus 4.7 <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.
Summary
systemctl is-activeevery 2s while READY/SERVING/IDLE_transitionso live-state entry/exit drives lifecycleTest plan
tests/slots/test_fail_watcher.pygreen (simulates unit dying, asserts ERROR + SSE within 5s; clean unload cancels watcher with no spurious push)🤖 Generated with Claude Code