Merge branch 'master' of https://github.com/mitchellh/packer
This commit is contained in:
commit
4cbaf7b95b
|
@ -62,12 +62,20 @@ func (s *stepCreateImage) Cleanup(multistep.StateBag) {
|
|||
|
||||
// WaitForImage waits for the given Image ID to become ready.
|
||||
func WaitForImage(client *gophercloud.ServiceClient, imageId string) error {
|
||||
maxNumErrors := 10
|
||||
numErrors := 0
|
||||
|
||||
for {
|
||||
image, err := images.Get(client, imageId).Extract()
|
||||
if err != nil {
|
||||
errCode, ok := err.(*gophercloud.UnexpectedResponseCodeError)
|
||||
if ok && errCode.Actual == 500 {
|
||||
log.Printf("[ERROR] 500 error received, will ignore and retry: %s", err)
|
||||
if ok && (errCode.Actual == 500 || errCode.Actual == 404) {
|
||||
numErrors++
|
||||
if numErrors >= maxNumErrors {
|
||||
log.Printf("[ERROR] Maximum number of errors (%d) reached; failing with: %s", numErrors, err)
|
||||
return err
|
||||
}
|
||||
log.Printf("[ERROR] %d error received, will ignore and retry: %s", errCode.Actual, err)
|
||||
time.Sleep(2 * time.Second)
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue