Treat PID 0 as dead in supervisor liveness check#4431
Merged
amirejaz merged 2 commits intostacklok:mainfrom Mar 30, 2026
Merged
Treat PID 0 as dead in supervisor liveness check#4431amirejaz merged 2 commits intostacklok:mainfrom
amirejaz merged 2 commits intostacklok:mainfrom
Conversation
During transport restart, ResetWorkloadPID sets process_id to 0 in the status file. isSupervisorProcessAlive only checked for an error from GetWorkloadPID, so (0, nil) was treated as a live supervisor. This caused thv restart to silently no-op during the transient window where PID is 0. Fixes stacklok#4429 Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Greg Katz <gkatz@indeed.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4431 +/- ##
==========================================
- Coverage 69.54% 69.53% -0.01%
==========================================
Files 487 487
Lines 50138 50138
==========================================
- Hits 34870 34865 -5
- Misses 12585 12589 +4
- Partials 2683 2684 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
amirejaz
approved these changes
Mar 30, 2026
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
isSupervisorProcessAliveonly checkederrfromGetWorkloadPID, not the PID value. During transport restart,ResetWorkloadPIDsetsprocess_idto 0, soGetWorkloadPIDreturns(0, nil). The function returnedtrue, causingthv restartto silently no-op during the 5-60s window where PID is 0.pid <= 0guard consistent with the pattern established in Guard against invalid PIDs in process operations #4401 forKillProcessandFindProcessFixes #4429
Type of change
Test plan
task test)task lint-fix)Special notes for reviewers
stopProcesshas the sameerr-only check at line 844. When PID is 0 it proceeds to callKillProcess(0), which is harmless (that function has its ownpid <= 0guard from #4401), but adding a guard there too would be a logical consistency improvement. Left out of this PR to keep the scope minimal.Generated with Claude Code