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

Correct Windows plugin restart when Reattach info is stale #6092

Closed
wants to merge 1 commit into from

Conversation

lachlanorr
Copy link

The Reattach info Nomad stores can get stale, whereby the pid no
longer refers to a live process.

This has happened to me regularly (but not always) when
troubleshooting plugin initialization and handshaking as I'm
frequently starting and killing nomad.

On Windows, when the go-plugin code calls FindProcess with a stale
pid, the following error is always returned:
os.SyscallError - 'OpenProcess: the paremter is incorrect'

On Unix systems, FindProcess never returns an error, at least as
presently defined in the go source code.

In order for Nomad to recognize this condition we need to bubble up
the ErrProcesNotFound error, with which we can then futher propogate
the SingletonPluginExited error from singleton.go.

With these changes in place, whenever a stale pid is found in the
Reattach info, Nomad now properly restarts the plugin exe.

The Reattach info Nomad stores can get stale, whereby the pid no
longer refers to a live process.

This has happened to me regularly (but not always) when
troubleshooting plugin initialization and handshaking as I'm
frequently starting and killing nomad.

On Windows, when the go-plugin code calls FindProcess with as stale
pid, the following error is always returned:
os.SyscallError - 'OpenProcess: the paremter is incorrect'

On Unix systems, FindProcess never returns an error, at least as
presently defined in the go source code.

In order for Nomad to recognize this condition we need to bubble up
the ErrProcesNotFound error, with which we can then futher propogate
the SingletonPluginExited error from singleton.go.

With these changes in place, whenever a stale pid is found in the
Reattach info, Nomad now properly restarts the plugin exe.
@hashicorp-cla
Copy link

hashicorp-cla commented Aug 8, 2019

CLA assistant check
All committers have signed the CLA.

@@ -780,7 +780,10 @@ func (c *Client) reattach() (net.Addr, error) {
// Verify the process still exists. If not, then it is an error
p, err := os.FindProcess(c.config.Reattach.Pid)
if err != nil {
return nil, err
// On Unix systems, FindProcess never returns an error.
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please open this diff on hashicorp/go-plugin

Copy link
Author

Choose a reason for hiding this comment

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

It is already there:
hashicorp/go-plugin#125

@tgross
Copy link
Member

tgross commented Dec 9, 2019

That fix to go-plugin was updated in #6426 and released in 0.10.2.

@tgross tgross closed this Dec 9, 2019
@github-actions
Copy link

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 Jan 24, 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.

None yet

4 participants