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

Executing a winrm command that shuts down the machine #161

Open
sneal opened this issue Feb 21, 2024 · 2 comments · May be fixed by #162
Open

Executing a winrm command that shuts down the machine #161

sneal opened this issue Feb 21, 2024 · 2 comments · May be fixed by #162

Comments

@sneal
Copy link
Contributor

sneal commented Feb 21, 2024

It appears a recent commit broke some assumptions in stembuild that executes a sysprep shutdown command that never finishes.

Is there a recommended method of executing a winrm command which may be interrupted by a shutdown? Previously we were expecting an error like winrm connection event: unknown error Post "http://10.220.41.242:5985/wsman": read tcp 10.220.41.9:34002->10.220.41.242:5985: read: connection timed out and just continuing when that happened. Now the winrm command never finishes and winrm command fetchOutput goes into an infinite loop waiting for the machine to come back up which will never happen.

@masterzen
Copy link
Owner

Indeed, we used to return early when timeouts were happening, now we try harder because it can happen the remote host just times out for long commands.
Beside making that behavior optional, I don't see exactly how to fix the problem, because both behavior are antinomic.
I'll think about it, but feel free to propose a fix.

@sneal
Copy link
Contributor Author

sneal commented Feb 28, 2024

I'll have to think on this as well. I'll have to look a little deeper as this may already exist, but I'd expect there to be some sort of configurable command timeout error that would eventually be returned to the caller vs waiting forever.

In this specific case we expect the connection to break - signaling command completion. So the behavior we really want is to execute the command and block until the machine stops responding. The command timeout seems like a good backstop, but I think ultimately in this case stembuild needs to kick off the winrm command one one goroutine and then in another poll for the machine to be shutdown (ideally querying the IaaS).

jpalermo added a commit to jpalermo/winrm that referenced this issue Mar 21, 2024
…e the command

Fixes masterzen#161 where commands that cause the host to shut down never complete
and run forever.
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

Successfully merging a pull request may close this issue.

2 participants