diff --git a/CHANGELOG.md b/CHANGELOG.md index 05a27871e..3e55e195c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,8 @@ BUG FIXES: * core: Concurrent map access is completely gone, fixing rare issues with runtime memory corruption. [GH-307] * core: Fix possible panic when ctrl-C during provisioner run. +* builder/digitalocean: Retry destroy a few times because DO sometimes + gives false errors. * provisioners/salt-masterless: Use filepath join to properly join paths. ## 0.3.5 (August 28, 2013) diff --git a/builder/digitalocean/step_create_droplet.go b/builder/digitalocean/step_create_droplet.go index 484d516eb..dcc369ac4 100644 --- a/builder/digitalocean/step_create_droplet.go +++ b/builder/digitalocean/step_create_droplet.go @@ -62,12 +62,20 @@ func (s *stepCreateDroplet) Cleanup(state multistep.StateBag) { log.Printf("Sleeping for %v, event_delay", c.RawEventDelay) time.Sleep(c.eventDelay) - err := client.DestroyDroplet(s.dropletId) - - curlstr := fmt.Sprintf("curl '%v/droplets/%v/destroy?client_id=%v&api_key=%v'", - DIGITALOCEAN_API_URL, s.dropletId, c.ClientID, c.APIKey) + var err error + for i := 0; i < 5; i++ { + err = client.DestroyDroplet(s.dropletId) + if err == nil { + break + } + + time.Sleep(2 * time.Second) + } if err != nil { + curlstr := fmt.Sprintf("curl '%v/droplets/%v/destroy?client_id=%v&api_key=%v'", + DIGITALOCEAN_API_URL, s.dropletId, c.ClientID, c.APIKey) + ui.Error(fmt.Sprintf( "Error destroying droplet. Please destroy it manually: %v", curlstr)) }