check for ip after timeout (#9748)

This commit is contained in:
Sylvia Moss 2020-08-12 10:39:12 +02:00 committed by GitHub
parent 9d453624ff
commit e475db6a66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -97,10 +97,16 @@ func (s *StepWaitForIp) Run(ctx context.Context, state multistep.StateBag) multi
for {
select {
case <-timeout:
cancel()
<-waitDone
if ip != "" {
state.Put("ip", ip)
log.Printf("[WARN] API timeout waiting for IP but one IP was found. Using IP: %s", ip)
return multistep.ActionContinue
}
err := fmt.Errorf("Timeout waiting for IP.")
state.Put("error", err)
ui.Error(err.Error())
cancel()
return multistep.ActionHalt
case <-ctx.Done():
cancel()
@ -144,7 +150,7 @@ loop:
// Check for ctx cancellation to avoid printing any IP logs at the timeout
select {
case <-ctx.Done():
return "", fmt.Errorf("IP wait cancelled")
return ip, fmt.Errorf("IP wait cancelled.")
default:
}