openstack: WaitForImage: treat 404 as retryable

Addresses comment at
https://github.com/mitchellh/packer/issues/1415#issuecomment-165739549
This commit is contained in:
Marc Abramowitz 2015-12-18 10:37:31 -08:00
parent b08b88b019
commit 4b9c4cc3e6
1 changed files with 2 additions and 2 deletions

View File

@ -69,13 +69,13 @@ func WaitForImage(client *gophercloud.ServiceClient, imageId string) error {
image, err := images.Get(client, imageId).Extract()
if err != nil {
errCode, ok := err.(*gophercloud.UnexpectedResponseCodeError)
if ok && errCode.Actual == 500 {
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] 500 error received, will ignore and retry: %s", err)
log.Printf("[ERROR] %d error received, will ignore and retry: %s", errCode.Actual, err)
time.Sleep(2 * time.Second)
continue
}