parallels/vmware: don't wait for shutdown command.
Resolves #4134 replaces/ closes #4379 Leaving Hyper-V builder alone for now until we can get a case that reproduces.
This commit is contained in:
parent
1109073f9a
commit
f1175c1921
|
@ -1,6 +1,7 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
|
@ -36,9 +37,15 @@ func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction {
|
|||
if s.Command != "" {
|
||||
ui.Say("Gracefully halting virtual machine...")
|
||||
log.Printf("Executing shutdown command: %s", s.Command)
|
||||
cmd := &packer.RemoteCmd{Command: s.Command}
|
||||
if err := cmd.StartWithUi(comm, ui); err != nil {
|
||||
err = fmt.Errorf("Failed to send shutdown command: %s", err)
|
||||
|
||||
var stdout, stderr bytes.Buffer
|
||||
cmd := &packer.RemoteCmd{
|
||||
Command: s.Command,
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
}
|
||||
if err := comm.Start(cmd); err != nil {
|
||||
err := fmt.Errorf("Failed to send shutdown command: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
|
@ -55,6 +62,8 @@ func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction {
|
|||
|
||||
select {
|
||||
case <-shutdownTimer:
|
||||
log.Printf("Shutdown stdout: %s", stdout.String())
|
||||
log.Printf("Shutdown stderr: %s", stderr.String())
|
||||
err := errors.New("Timeout while waiting for machine to shut down.")
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
|
|
|
@ -57,14 +57,6 @@ func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction {
|
|||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
// Wait for the command to run so we can print std{err,out}
|
||||
// We don't care if the command errored, since we'll notice
|
||||
// if the vm didn't shut down.
|
||||
cmd.Wait()
|
||||
|
||||
log.Printf("Shutdown stdout: %s", stdout.String())
|
||||
log.Printf("Shutdown stderr: %s", stderr.String())
|
||||
|
||||
// Wait for the machine to actually shut down
|
||||
log.Printf("Waiting max %s for shutdown to complete", s.Timeout)
|
||||
shutdownTimer := time.After(s.Timeout)
|
||||
|
@ -76,6 +68,8 @@ func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction {
|
|||
|
||||
select {
|
||||
case <-shutdownTimer:
|
||||
log.Printf("Shutdown stdout: %s", stdout.String())
|
||||
log.Printf("Shutdown stderr: %s", stderr.String())
|
||||
err := errors.New("Timeout while waiting for machine to shut down.")
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"github.com/mitchellh/iochan"
|
||||
)
|
||||
|
||||
// CmdDisconnect is a sentry value to indicate a RemoteCmd
|
||||
// CmdDisconnect is a sentinel value to indicate a RemoteCmd
|
||||
// exited because the remote side disconnected us.
|
||||
const CmdDisconnect int = 2300218
|
||||
|
||||
|
|
Loading…
Reference in New Issue