Skip to content

fix(e2e): send SIGINT on teardown to prevent orphan processes#785

Merged
doringeman merged 1 commit intomainfrom
e2e
Mar 25, 2026
Merged

fix(e2e): send SIGINT on teardown to prevent orphan processes#785
doringeman merged 1 commit intomainfrom
e2e

Conversation

@doringeman
Copy link
Contributor

The e2e test teardown was using exec.CommandContext which sends SIGKILL when the context is cancelled. This kills the model-runner server instantly without giving it a chance to shut down its child processes (llama.cpp, vllm-metal), leaving orphan processes running on their ports. Setting Cmd.Cancel to send os.Interrupt instead triggers the same graceful shutdown path as Ctrl+C, which properly cleans up all backend processes.

Note that os.Interrupt is not supported on Windows , so a platform-specific mechanism will be needed when Windows e2e tests are added.

Signed-off-by: Dorin Geman <dorin.geman@docker.com>
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider making the custom Cancel function resilient to being invoked before the process has started (e.g., checking server.Process != nil before signaling) to avoid potential nil pointer issues if the context is canceled early.
  • You may want to add a follow-up mechanism to escalate from os.Interrupt to a Kill after a timeout if the server fails to shut down gracefully, to avoid tests hanging indefinitely on a stuck child process.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider making the custom Cancel function resilient to being invoked before the process has started (e.g., checking server.Process != nil before signaling) to avoid potential nil pointer issues if the context is canceled early.
- You may want to add a follow-up mechanism to escalate from os.Interrupt to a Kill after a timeout if the server fails to shut down gracefully, to avoid tests hanging indefinitely on a stuck child process.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a graceful shutdown mechanism for the server process in e2e tests by setting the server.Cancel function to send an os.Interrupt signal. However, the current implementation will cause issues on Windows, leading to orphan processes, as os.Interrupt is not supported on that platform. The feedback suggests adding a runtime check to use server.Process.Kill() for Windows and os.Interrupt for other operating systems to ensure correct behavior across all platforms.

@doringeman doringeman merged commit 91e9b08 into main Mar 25, 2026
12 checks passed
@doringeman doringeman deleted the e2e branch March 25, 2026 09:22
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.

2 participants