Fix vsphere boot command and check for context cancelation when waiting for ip (#9739)
This commit is contained in:
parent
d826711e7a
commit
80960d7a64
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue