Commit aedd1555 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/digitalocean: properly cleanup goroutines for status checking

parent 4af230a4
......@@ -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
}
}
}()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment