diff --git a/builder/digitalocean/wait.go b/builder/digitalocean/wait.go index 388e27978..ba2b03cb0 100644 --- a/builder/digitalocean/wait.go +++ b/builder/digitalocean/wait.go @@ -9,6 +9,9 @@ import ( // waitForState simply blocks until the droplet is in // a state we expect, while eventually timing out. func waitForDropletState(desiredState string, dropletId uint, client *DigitalOceanClient, timeout time.Duration) error { + done := make(chan struct{}) + defer close(done) + result := make(chan error, 1) go func() { attempts := 0 @@ -29,6 +32,15 @@ func waitForDropletState(desiredState string, dropletId uint, client *DigitalOce // Wait 3 seconds in between time.Sleep(3 * time.Second) + + // Verify we shouldn't exit + select { + case <-done: + // We finished, so just exit the goroutine + return + default: + // Keep going + } } }()