Skip to content

Synchronize updater child-exit and health handoff tests - #1198

Merged
jatmn merged 2 commits into
mainfrom
fix/queue-666-updater-child-liveness
Dec 6, 2026
Merged

jatmn merged 2 commits into
mainfrom
fix/queue-666-updater-child-liveness

Conversation

@jatmn

@jatmn jatmn commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

Part of #666. Seventeen updater tests now observe child exit, socket ownership and admission to the control read directly. They keep the real child processes, launcher HTTP responses and occupied SQLite connections. The supervisor's observation points compile only in test builds.

Four crash-recovery tests could fail if the test task was descheduled for the entire five-second backoff. They now check the first retry deadline and exercise the supervisor immediately before that deadline. The three cases that restart the child advance the fixture clock to the deadline and observe the replacement.

Verification

  • Pinned Dylint reproduced the 47 assigned findings. On the integrated branch all 47 are gone, and the remaining 37 updater findings match the separate reservation and selection group.
  • All 187 updater package tests passed. All 17 affected cases passed 20 serial and 12 contended runs each on the integrated commit, totaling 544 executions.
  • A 5.3-second pause before the held tick made each of the four crash tests fail on the earlier candidate. With the fixed clock all four passed the same pause, and removing the backoff made all four fail at the exact-deadline assertion.
  • All five general exit scenarios passed with the kernel returning ENOSYS for pidfd_open. Each failed in the prior version. The fixture uses waitid with P_PID and WNOWAIT to preserve the exit status for the supervisor.
  • Formatting, updater all-target Clippy, pinned Dylint and repository contracts passed. The initial implementation also caught 19 deliberately injected faults. External services are represented by local fixtures.

Tested together with #1199, the two PRs merge cleanly into tree a5e71a3b61cefc388b0f472960868d7aa0035d32. On that exact tree, pinned Dylint passed across the full workspace with zero test-flake diagnostics, and all 187 updater package tests passed.

Summary by Sourcery

Make updater child-exit, health handoff, and crash-retry tests deterministic under scheduling delays.

Enhancements:

  • Strengthen updater crash-recovery and health-handoff tests with explicit observations of child exit, health ownership, and control-read admission, and deterministic checks around restart backoff deadlines.

Tests:

  • Improve reliability of updater process and recovery tests by replacing scheduler-dependent polling with direct event observations and fixture-clock control.

@jatmn
jatmn marked this pull request as ready for review December 5, 2026 23:36

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: crates/updater/src/controller_tests.rs:5749


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread crates/updater/src/controller_tests.rs Resolved
pullfrog[bot]
pullfrog Bot previously approved these changes Dec 5, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Two non-blocking test findings.

Approach Directly observing child exit, health handoff, and entry into the control read makes the ordering assertions more reliable while exercising the real launcher, child processes, and SQLite pool.

Reviewed changes I reviewed both updater files and ran all 146 launcher tests successfully with cargo test --locked -p jmodguard-updater --bin jmodguard-launcher.

  • Child exit and health handoff. The tests await process, task, or marker events and probe the launcher’s HTTP responses while database work is stalled.
  • Retry timing. Three crash scenarios tick just before the first retry deadline on a fixed clock. Two also verify that the replacement starts at the deadline.

Non-blocking

  • The pending-receipt test still races the crash deadline. If the test task is descheduled for a full POLL after recording the crash, its next tick() can restart the child and fail the hold assertions. Use the fixture clock already available in this PR to drive the held tick and the retry. Pending-receipt fixture
  • Five general child-exit tests now require pidfd_open. The new calls panic on hosts where the syscall is unavailable, including Linux kernels before 5.3. The launcher supports these hosts through its PID fallback. Give the fixture wait a bounded, non-reaping PID fallback so these scenarios can still run there. Fixture call · Launcher fallback · Linux syscall documentation

Pullfrog  | Fix it ➔ | View workflow run | Using gpt-6.2-sol | 𝕏

jatmn commented Dec 5, 2026

Copy link
Copy Markdown
Owner Author

Both findings are addressed in ed51674. The pending-receipt case drives the real supervisor one nanosecond before the first crash deadline and again exactly at it. A 5.3-second pause failed the old case and passed the revised one. The general child-exit fixtures now use a bounded waitid(P_PID, …, WEXITED | WNOWAIT) observation, leaving the exit status available to the launcher. Forcing pidfd_open to return ENOSYS failed all five general scenarios on the prior code and passed all five on this revision.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed 58ebc63..ed51674. All 146 launcher tests passed. The five general child-exit cases also passed with pidfd_open forced to return ENOSYS.

  • Replaced the exit wait. The fixture now uses waitid(P_PID, …, WNOWAIT) so the supervisor can still reap the child when it resumes.
  • Drove the pending-receipt retry deadline. The test checks that the restart is held one nanosecond before the deadline and observes the replacement start at the deadline while SQLite is blocked.
  • Made auth recovery ordering explicit. The unsaved-candidate case uses current-thread Tokio and checks that normal() handles the exit with the watcher disarmed.

Pullfrog  | View workflow run | Using gpt-6.2-sol | 𝕏

@jatmn
jatmn merged commit 87759de into main Dec 6, 2026
30 of 32 checks passed
@jatmn
jatmn deleted the fix/queue-666-updater-child-liveness branch December 6, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant