fix(embed): define daemon stop() success by port occupancy, not the health probe - #3171
Open
Alan5168 wants to merge 1 commit into
Open
fix(embed): define daemon stop() success by port occupancy, not the health probe#3171Alan5168 wants to merge 1 commit into
Alan5168 wants to merge 1 commit into
Conversation
…ealth probe stop() used is_running() -- a 2s /health probe -- both as its already-stopped guard and as its final success condition. A daemon that is alive but busy (slow provider call, model load) fails that probe, so 'daemon stop' returned True without sending any signal, and a failed termination or missing PID also fell through to a reported success. Resolve the port from the profile and use occupancy for every decision: already stopped only when nothing is bound; bound port with no findable PID is a failure; a False from _kill_process() is a failure; after the kill, success means the listener is gone. This mirrors the occupancy/health separation _clear_port() already uses. Closes vectorize-io#3169
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.
Implements the contract agreed in #3169 with @koriyoshi2041.
stop()was usingis_running()— the 2s/healthprobe — both as its already-stopped guard and as its final success condition. A daemon that is alive but busy fails that probe, sodaemon stopreturned success without sending any signal (repro in the issue: nothing killed, port still bound,/healthback to 200 once the block cleared). As koriyoshi2041 pointed out, the tail of the function had the same problem: aFalsefrom_kill_process()was discarded, and a bound port with no findable PID also fell through to the health-based wait, so both failure paths could exitTrue.Every decision is now based on port occupancy:
TrueFalse_kill_process()returnsFalse→False_is_port_in_use(), not/healthSame occupancy/health separation
_clear_port()already uses.Regression tests cover the three cases named in the issue thread — busy listener, failed termination, missing PID — plus already-stopped and lingering-listener-after-kill. The busy-listener test also patches
is_runningto raise, pinning that no path instop()consults the responsiveness probe. All five fail against the previous implementation (verified by reverting just the production change);hindsight-embedsuite is green with the fix (153 passed).One behavioural note: "port bound but no PID found" previously could report success via the wait loop; per the contract it now reports failure, which callers see as a failed stop instead of a silent no-op.
Closes #3169