From 9f647ba2bb01dd5b824fbac4b5e84b9d312de9b8 Mon Sep 17 00:00:00 2001 From: jhawk28 Date: Fri, 19 Mar 2021 08:27:05 -0400 Subject: [PATCH] try to retype key if an error is received (#10541) --- builder/vsphere/common/step_boot_command.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/builder/vsphere/common/step_boot_command.go b/builder/vsphere/common/step_boot_command.go index 7a56f9e06..5847d1f08 100644 --- a/builder/vsphere/common/step_boot_command.go +++ b/builder/vsphere/common/step_boot_command.go @@ -99,7 +99,19 @@ func (s *StepBootCommand) Run(ctx context.Context, state multistep.StateBag) mul Shift: shift, }) if err != nil { - return fmt.Errorf("error typing a boot command (code, down) `%d, %t`: %w", code, down, err) + // retry once if error + ui.Error(fmt.Errorf("error typing a boot command (code, down) `%d, %t`: %w", code, down, err).Error()) + ui.Say("trying key input again") + time.Sleep(s.Config.BootGroupInterval) + _, err = vm.TypeOnKeyboard(driver.KeyInput{ + Scancode: code, + Ctrl: keyCtrl, + Alt: keyAlt, + Shift: shift, + }) + if err != nil { + return fmt.Errorf("error typing a boot command (code, down) `%d, %t`: %w", code, down, err) + } } return nil }