Skip to content

XERK-2580: Stop the one-shot kill from signalling every process - #1372

Merged
xerhab merged 1 commit into
mainfrom
XERK-2580-oneshot-kill-guard
Nov 1, 2026
Merged

xerhab merged 1 commit into
mainfrom
XERK-2580-oneshot-kill-guard

Conversation

@xerhab

@xerhab xerhab commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Summary: The agent's one-shot cleanup can no longer kill every process its user owns when it is handed a fake or invalid process id. This closes the last copy of the bug that repeatedly took the TrueNAS agent down.

Part of XERK-2580

Why

What changed

  • SessionManager._kill_oneshot_proc passes the pid through _signalable_pid. If the pid isn't a real one, it falls back to proc.kill(), as the sibling kill sites already do.
  • New test test_a_mocked_oneshot_proc_is_never_killpg_d in TestKillpgNeverHitsPidOne.

Risk

Low. Only a pid that isn't a positive integer above 1 behaves differently. A real child is still group-killed. To roll back, revert this commit.

Testing

QA result: PASS. QA confirmed a bogus pid (MagicMock, 1, 0, -1, True, None) never reaches killpg. A live one-shot group (child plus grandchildren) went from 4 processes to 0 on shutdown. Four deliberate breakages of the guard were each caught by the new test.
Not tested: Windows (that branch is unchanged) and a full end-to-end _handle_shutdown of a running manager.

Test evidence
  • Full agent suite: pytest tests/, 4451 passed, 26 skipped. QA reran it under a kill guard: unittest discover, 4477 OK.
  • Kill-site classes and one-shot classes: 151 tests OK.
  • With the guard removed, the new test fails (5 subtests).

Follow-ups

  • test_a_shutdown_landing_inside_popen_still_kills_that_child checks only the direct child's exit, not the process group (Low, pre-existing). Rolled into XERK-2584.

_kill_oneshot_proc (from XERK-2545, #1339) still killpg'd proc.pid directly.
A mocked Popen's pid coerces to 1, and killpg(1) is kill(-1): the exact call
that took TrueNAS down. Route it through _signalable_pid like its siblings.
@xerhab
xerhab merged commit 73c70be into main Nov 1, 2026
5 checks passed
@xerhab
xerhab deleted the XERK-2580-oneshot-kill-guard branch November 1, 2026 14:09
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