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

B 2117 windows group process #4153

Merged
merged 2 commits into from
Apr 17, 2018

Conversation

ninoles
Copy link
Contributor

@ninoles ninoles commented Apr 14, 2018

This PR is a best attempt to resolve #2117. Windows processes never cleanly map to Posix semantic so there is a couple of issues here:

  • We currently supposed the process is a console process. This will allow for the more common case of subprocess handling which are subprocesses launched from a shell script.
  • Other signals like Ctrl-C, Ctrl-Close, Ctrl-Terminate aren't handled. It would required additional config support and testing for correctly mapping them. As a workaround, it is possible to handle such case by creating a launcher that handle the Ctrl-break and kill its children with the appropriate event.
  • I do my best to limit the changes to what's necessary to make it run and build. The Syslog handling function are however duplicate between the executor_unix.go and executor_windows.go files. I'm not sure why those functions were in executor_unix.go initially (and why executor_unix.go has so many build targets), but may be they can go back in executor.go.

ninoles added 2 commits April 14, 2018 13:58
- Set CREATE_NEW_PROCESS_GROUP for Windows subprocess.
- Ensure we only kill actual process that need to.
@schmichael schmichael self-assigned this Apr 16, 2018
Copy link
Member

@schmichael schmichael left a comment

Choose a reason for hiding this comment

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

This looks great! Is there a job file you've been using to test this? I'd love to give it a spin myself before merging.

Thanks for the PR!

@@ -3,6 +3,9 @@
IMPROVEMENTS:
* client: Create new process group on process startup. [[GH-3572](https://github.com/hashicorp/nomad/issues/3572)]

BUG FIXES:
* driver/exec: Create process group for Windows process and send Ctrl-Break signal on Shutdown [[GH-2117](https://github.com/hashicorp/nomad/issues/2117)]
Copy link
Member

Choose a reason for hiding this comment

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

We use the pull request number instead of the issue number for these links. The issues in the URL is just a typo we haven't fixed in our make changelogfmt script because Github is nice enough to redirect it anyway. :)


// configure new process group for child process
func (e *UniversalExecutor) setNewProcessGroup() error {
// We need to check that as build flags includes windows for this file
Copy link
Member

Choose a reason for hiding this comment

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

Remove this comment

"github.com/hashicorp/nomad/client/driver/logging"
)

func (e *UniversalExecutor) LaunchSyslogServer() (*SyslogServerState, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Like you pointed out in the issue description I don't think there was any reason for this to be in the executor_unix.go file instead of executor.go proper. Would you mind moving it there to avoid duplication?

return err
}
return nil
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove else statement and just fall through to proc.Kill()

}
}

func (e *UniversalExecutor) shutdownProcess(proc *os.Process) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment that this sends the shutdown signal and doesn't necessarily kill the process

@@ -0,0 +1,111 @@
// +build windows
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary since the file has _windows.go

@schmichael
Copy link
Member

Since #3572 broke the Windows build and fixing it would conflict with this PR, I'm going to merge this as-is and fixup the comments in a followup PR.

Thanks for the contribution @ninoles!

@schmichael schmichael merged commit 081ef6b into hashicorp:master Apr 17, 2018
schmichael added a commit that referenced this pull request Apr 17, 2018
* `driver/raw_exec` instead of `exec` because `exec` driver isn't
  supported on Windows
* Link to PR not issue
schmichael added a commit that referenced this pull request Apr 18, 2018
* `driver/raw_exec` instead of `exec` because `exec` driver isn't
  supported on Windows
* Link to PR not issue
@github-actions
Copy link

github-actions bot commented Mar 6, 2023

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

raw_exec process children aren't kill properly
3 participants