fix: svcinit tolerates service crash in ibazel reload mode#73
Open
jaqx0r wants to merge 6 commits into
Open
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3187d60290
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
- Replace blocking `for range servicesErrCh` with non-blocking drain so reload proceeds even when no crash errors are pending - Stop() returns nil for already-dead processes instead of propagating ESRCH from killGroup - Hot-reload stdin.Write failure falls back to full restart instead of panicking Fixes hermeticbuild#72
…ited A crashed service may leave child processes alive in the same process group (holding a port or stdout). Previously we returned nil immediately when isDone() was true, skipping the killGroup call. Now we always attempt the group kill and discard the error (ESRCH means the group is already gone, which is fine). Addresses review comment on hermeticbuild#73.
3187d60 to
a8eaabf
Compare
- Log each discarded service error during pre-reload drain instead of silently dropping them - Explicitly close old stdin pipe before stopping crashed service in hot-reload fallback - Log StopWithSignal error in crash fallback instead of silently ignoring
…s in upstream Drain block
dzbarsky
reviewed
Jun 24, 2026
- Move old instance capture above stdin.Write in hot-reload fallback - Remove redundant killGroup call in isDone() fast-path; first killGroup call already handled group cleanup
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
When running under
ibazel run --@rules_itest//:enable_per_service_reload, if a service crashes, svcinit panics on the next reload notification. Additionally, the existing drain loop silently discards crash errors — this PR adds logging to make them visible.Changes
cmd/svcinit/main.go): The existingDrain:loop drainsservicesErrChnon-blocking before reload. This PR addslog.Printffor each discarded error so crashes are visible in output.StopWithSignal()tolerates dead processes (runner/service_instance.go): After callingkillGroup, if the process raced to exit (isDone()), return nil instead of propagating the error. The initialkillGroupcall already attempted group cleanup.runner/runner.go): Ifstdin.Writefails for a hot-reloadable service (broken pipe from crash), explicitly close the old stdin pipe, log the stop error, and fall back to a full stop+restart instead of propagating the error.Fixes #72