Fix vsphere boot command and check for context cancelation when waiting for ip (#9739)

This commit is contained in:
Sylvia Moss 2020-08-10 18:16:19 +02:00 committed by GitHub
parent d826711e7a
commit 80960d7a64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -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)

View File

@ -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)