Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Agent doesn't survive helper invocation when running under Bazel #22

Open
malt3 opened this issue Jan 4, 2025 · 0 comments
Open

Comments

@malt3
Copy link
Collaborator

malt3 commented Jan 4, 2025

Describe the bug

On Windows, the agent process cannot daemonize when run as a subprocess of the helper client under Bazel (doing this in a shell directly with credential-helper get works fine).

I think this is a result of Bazel trying very hard to keep track of all child processes when launching a process.
On Windows, I noticed that Bazel creates a job object and sets it up so child processes cannot detach into their own job.
After a process is done, Bazel terminates whole job object, including all child processes inside of it.
So far, I haven't found a reliable way to beak out of the job group.

Ideas I have:

  • Try using Windows task scheduler schtasks to spawn process outside of job object using a one-off task (probably messy, may leave dangling tasks)
  • Variation of above, but make this a user facing feature: Have a credential-helper task-install (or similar) command that users must run on Windows in order to have the agent running for their Bazel codebase.
  • Have user facing command to just spawn detached agent process on Windows: credential-helper agent-daemonize. Users would need to run this before starting their Bazel server process.
  • As a short term workaround, make agent optional on Windows and handle death of agent process more graceful. Also consider not starting any agent process and simply trying to connect to the agent once.

To Reproduce

Use the credential helper in Bazel (via --credential_helper) on Windows.
The helper client process dies with messages like this: storing response in cache: write unix @->run\agent.sock: wsasend: An existing connection was forcibly closed by the remote host..
Using ProcMon, I was able to verify that agents are killed while in use.

Expected behavior

Multiple client processes can connect to the same agent.
After Bazel is done, the same agent process is still running in the background (test via Get-Process credential-helper).

Environment

  • OS name + version: Windows 11 24H2
  • Version of the code: 9021eb3

Additional context
Add any other context about the problem here.

@malt3 malt3 changed the title [Windows] Agent doesn't survive helper invocation [Windows] Agent doesn't survive helper invocation when running under Bazel Jan 4, 2025
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

No branches or pull requests

1 participant