windows: set job object for executor and children (#24214)

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: https://github.com/hashicorp/nomad/issues/23668
Ref: https://learn.microsoft.com/en-us/windows/win32/procthread/job-objects
This commit is contained in:
Tim Gross
2024-10-16 09:20:26 -04:00
committed by GitHub
parent 0f6561bdfe
commit 6b8ddff1fa
9 changed files with 369 additions and 142 deletions

View File

@@ -87,6 +87,8 @@ jobs:
gotestsum --format=short-verbose \
--junitfile results.xml \
github.com/hashicorp/nomad/drivers/docker \
github.com/hashicorp/nomad/drivers/rawexec \
github.com/hashicorp/nomad/drivers/shared/executor \
github.com/hashicorp/nomad/client/lib/fifo \
github.com/hashicorp/nomad/client/logmon \
github.com/hashicorp/nomad/client/allocrunner/taskrunner/template \