From fe8d99fd8ad28b76c2aeafcd2bda4bdfa4c713b7 Mon Sep 17 00:00:00 2001 From: Taliesin Sisson Date: Sun, 1 Nov 2015 21:18:48 +0000 Subject: [PATCH] If we are not getting the exit code assigned then default to it being successful Useful to know what the exit code is if there is an error --- builder/hyperv/common/step_shutdown.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/builder/hyperv/common/step_shutdown.go b/builder/hyperv/common/step_shutdown.go index 62bbab21f..21a1e963d 100644 --- a/builder/hyperv/common/step_shutdown.go +++ b/builder/hyperv/common/step_shutdown.go @@ -40,6 +40,7 @@ func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction { var stdout, stderr bytes.Buffer cmd := &packer.RemoteCmd{ + ExitStatus: 0, Command: s.Command, Stdout: &stdout, Stderr: &stderr, @@ -57,18 +58,13 @@ func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction { // If the command failed to run, notify the user in some way. if cmd.ExitStatus != 0 { state.Put("error", fmt.Errorf( - "Shutdown command has non-zero exit status.\n\nStdout: %s\n\nStderr: %s", - stdout.String(), stderr.String())) + "Shutdown command has non-zero exit status.\n\nExitStatus: %d\n\nStdout: %s\n\nStderr: %s", + cmd.ExitStatus, stdout.String(), stderr.String())) return multistep.ActionHalt } - if stdout.Len() > 0 { - log.Printf("Shutdown stdout: %s", stdout.String()) - } - - if stderr.Len() > 0 { - log.Printf("Shutdown stderr: %s", stderr.String()) - } + 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)