-
Notifications
You must be signed in to change notification settings - Fork 2k
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: set job object for executor and children #24214
Conversation
b8faffd
to
2e2a26d
Compare
On Windows, if the `raw_exec` driver's executor exits, the child processes are not also killed. Create a Windows "job object" (not to be confused with a Nomad job) and add the executor to it. Child processes of the executor will inherit the job automatically. When the handle to the job object is freed (on executor exit), the job itself is destroyed and this causes all processes in that job to exit. Fixes: #23668 Ref: https://learn.microsoft.com/en-us/windows/win32/procthread/job-objects
2e2a26d
to
e4bd861
Compare
As noted in sidebar conversation I'm going to get |
08b81f4
to
c298b8b
Compare
@@ -237,103 +236,6 @@ func TestRawExecDriver_StartWait(t *testing.T) { | |||
require.NoError(harness.DestroyTask(task.ID, true)) | |||
} | |||
|
|||
func TestRawExecDriver_StartWaitRecoverWaitStop(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewers: this is moved to driver_unix_test.go
unchanged, including any modernization to use shoenig/test
, t.Cleanup
, etc. I'll take a second pass over these files in a separate refactoring PR to do all that.
@@ -59,15 +59,6 @@ var ( | |||
compute = topology.Compute() | |||
) | |||
|
|||
type testExecCmd struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewers: this whole file is marked !windows
now, so I moved these helpers into utils_test.go
c298b8b
to
e066745
Compare
e066745
to
a855e50
Compare
On Windows, if the
raw_exec
driver's executor exits, the child processes are not also killed. Create a Windows "job object" (not to be confused with a Nomad job) and add the executor to it. Child processes of the executor will inherit the job automatically. When the handle to the job object is freed (on executor exit), the job itself is destroyed and this causes all processes in that job to exit.Fixes: #23668
Ref: https://hashicorp.atlassian.net/browse/NET-11234
Ref: https://learn.microsoft.com/en-us/windows/win32/procthread/job-objects
Note: automated testing for this will need to be end-to-end but we're not running Windows on nightly anymore.I've verified the behavior works as expected using Process Explorer. Killing the executor kills all child processes as expected. Killing the root child process causes the executor to exit (as usual) and that in turn kills any child processes that didn't exit already.Edit: added tests, which requires changing what runs in CI as well