builder/triton: Wait for ImageCreation State

A bug was reported to Joyent, that sometimes packer UI reports that an image was created but it wasn't actually available in Triton for use. We believe that there was a bug uploading that image to Manta but that the metadata of the image was already populated and thus packer was reporting success as it was just checking for the metadata presence

This PR changes Packer to wait for the state of the image to be `active` to make sure that it has fully uploaded and is ready for use

```
==> triton: Stopping source machine (61647c3c-f2bf-4e30-b4bc-f076d3b01522)...
==> triton: Waiting for source machine to stop (61647c3c-f2bf-4e30-b4bc-f076d3b01522)...
==> triton: Creating image from source machine...
==> triton: Waiting for image to become available...
==> triton: Deleting source machine...
==> triton: Waiting for source machine to be deleted...
Build 'triton' finished.

==> Builds finished. The artifacts of successful builds are:
--> triton: Image was created: c2537582-34c7-42ea-bd11-b6ed499d5831
```
This commit is contained in:
stack72 2017-11-08 16:33:15 +02:00
parent d00f884e71
commit 450a233303
1 changed files with 2 additions and 3 deletions

View File

@ -4,9 +4,8 @@ import (
"context"
"errors"
"net/http"
"time"
"sort"
"time"
"github.com/hashicorp/packer/packer"
"github.com/joyent/triton-go/client"
@ -200,7 +199,7 @@ func (d *driverTriton) WaitForImageCreation(imageId string, timeout time.Duratio
if image == nil {
return false, err
}
return image.OS != "", err
return image.State == "active", err
},
3*time.Second,
timeout,