diff --git a/builder/vsphere/common/step_boot_command.go b/builder/vsphere/common/step_boot_command.go index c9cc2845b..4ad4a760c 100644 --- a/builder/vsphere/common/step_boot_command.go +++ b/builder/vsphere/common/step_boot_command.go @@ -87,11 +87,16 @@ func (s *StepBootCommand) Run(ctx context.Context, state multistep.StateBag) mul keyShift = down } + shift := down + if keyShift { + shift = keyShift + } + _, err := vm.TypeOnKeyboard(driver.KeyInput{ Scancode: code, Ctrl: keyCtrl, Alt: keyAlt, - Shift: keyShift, + Shift: shift, }) if err != nil { return fmt.Errorf("error typing a boot command (code, down) `%d, %t`: %w", code, down, err) diff --git a/builder/vsphere/common/step_wait_for_ip.go b/builder/vsphere/common/step_wait_for_ip.go index 3c05916b3..7ade58c8f 100644 --- a/builder/vsphere/common/step_wait_for_ip.go +++ b/builder/vsphere/common/step_wait_for_ip.go @@ -140,6 +140,14 @@ loop: if err != nil { return "", err } + + // Check for ctx cancellation to avoid printing any IP logs at the timeout + select { + case <-ctx.Done(): + return "", fmt.Errorf("IP wait cancelled") + default: + } + if prevIp == "" || prevIp != ip { if prevIp == "" { log.Printf("VM IP aquired: %s", ip)