From 450a2333038a2cf531492b8e758f57034fd06194 Mon Sep 17 00:00:00 2001 From: stack72 Date: Wed, 8 Nov 2017 16:33:15 +0200 Subject: [PATCH] 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 ``` --- builder/triton/driver_triton.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builder/triton/driver_triton.go b/builder/triton/driver_triton.go index 19e1e1902..5e6acffef 100644 --- a/builder/triton/driver_triton.go +++ b/builder/triton/driver_triton.go @@ -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,