Add cooperative drain controls for ephemeral runners - #4708
Draft
ashi009 wants to merge 2 commits into
Draft
Conversation
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.
Drafted with Codex assistance; open as a draft for author review.
Summary
Adds cooperative drain for
--ephemeralrunners with two explicit, independent inputs:run --drain-on-sigusr1: SIGUSR1 latches a drain request on Linux/macOS, without a control file.run --drain-file PATH: watches a supervisor-owned file at a configurable location. No default path and no writes to the installation directory. The two inputs can be enabled together.Refs #2190 (original graceful-shutdown request) and #2582 (SIGINT follow-up). Credits #4461 for the sentinel approach. Persistent-runner support and existing SIGINT/SIGTERM semantics are unchanged.
Implementation
DrainRequestowns a shared, thread-safe latch and optional signal registration. Observed requests survive file removal and listener-session restarts, but not process restarts.ShutdownAsyncearly and cancel the worker.For read-only containers, use the signal input or a separately mounted runtime directory for the optional file. Send SIGUSR1 directly to the opted-in listener after it is ready, not to the shell/service wrapper. The existing wrapper stop path can force-kill after 30 seconds and is not the drain interface.
Verification
759385a3510197a58b5c08dc1f373b74b9f4643b; the unmodified baseline passed five and timed out in four idle/pre-listen cases.DrainRequestsource and verified actual SIGUSR1 delivery without a file, optional file selection, and latching after file removal../dev.sh formatpassed. The updated full regression suite still needs CI; upstream workflow runs currently require maintainer approval. The earlier file-only results are not claimed as coverage of the new signal integration.Idle latency includes outstanding long polls. Ambiguous delivery after transport failures, forced termination, and actual runner upgrades are outside the verification claims.