Merge pull request #7553 from hashicorp/fix_7404

[WIP] add 30 minute timeout for destroying a VM
pull/7605/head
Megan Marsh 7 years ago committed by GitHub
commit c1d69b1f20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,6 +3,7 @@ package common
import (
"context"
"fmt"
"log"
"time"
"github.com/hashicorp/packer/helper/multistep"
@ -66,12 +67,19 @@ func (s *StepRegister) Cleanup(state multistep.StateBag) {
ui.Error(fmt.Sprintf("Error destroying VM: %s", err))
}
// Wait for the machine to actually destroy
start := time.Now()
for {
destroyed, _ := remoteDriver.IsDestroyed()
destroyed, err := remoteDriver.IsDestroyed()
if destroyed {
break
}
log.Printf("error destroying vm: %s", err)
time.Sleep(1 * time.Second)
if time.Since(start) >= time.Duration(30*time.Minute) {
ui.Error("Error unregistering VM; timed out. You may " +
"need to manually clean up your machine")
break
}
}
}
}

Loading…
Cancel
Save