diff --git a/iaas/digitalocean/iaas.go b/iaas/digitalocean/iaas.go index 35bd1dbd4b..6a2d0cb686 100644 --- a/iaas/digitalocean/iaas.go +++ b/iaas/digitalocean/iaas.go @@ -152,7 +152,7 @@ func (i *digitalOceanIaas) DeleteMachine(m *iaas.Machine) error { // PowerOff force the shutdown action, _, err = i.client.DropletActions.PowerOff(context.Background(), machineId) if err != nil { - return err + return errors.WithStack(err) } } u, _ := i.base.GetConfigString("url") @@ -161,11 +161,11 @@ func (i *digitalOceanIaas) DeleteMachine(m *iaas.Machine) error { defer cancel() err = util.WaitForActive(ctx, i.client, uri) if err != nil { - return err + return errors.WithStack(err) } resp, err := i.client.Droplets.Delete(context.Background(), machineId) if err != nil { - return err + return errors.WithStack(err) } if resp.StatusCode != 204 { return errors.New("failed to delete machine") diff --git a/iaas/digitalocean/iaas_test.go b/iaas/digitalocean/iaas_test.go index 0ab722122a..021c0eefa9 100644 --- a/iaas/digitalocean/iaas_test.go +++ b/iaas/digitalocean/iaas_test.go @@ -122,13 +122,16 @@ func (s *digitaloceanSuite) TestDeleteMachine(c *check.C) { if r.URL.Path == "/v2/droplets/503/actions" { fmt.Fprintln(w, `{"action":{"id": 123456, "status": "in-progress", "started_at": "2014-11-04T17:08:03Z", "resource_id": 503, "resource_type": "droplet"}}`) } + if r.URL.Path == "/v2/actions/123456" { + fmt.Fprintln(w, `{"action":{"id": 123456, "status": "completed", "started_at": "2014-11-04T17:08:03Z", "resource_id": 503, "resource_type": "droplet"}}`) + } })) defer fakeServer.Close() config.Set("iaas:digitalocean:url", fakeServer.URL) do := newDigitalOceanIaas("digitalocean") machine := iaas.Machine{Id: "503", CreationParams: map[string]string{"projectid": "projid"}} err := do.DeleteMachine(&machine) - c.Assert(err, check.IsNil) + c.Assert(err, check.IsNil, check.Commentf("%+v", err)) } func (s *digitaloceanSuite) TestDeleteMachineFailure(c *check.C) { @@ -140,6 +143,9 @@ func (s *digitaloceanSuite) TestDeleteMachineFailure(c *check.C) { if r.URL.Path == "/v2/droplets/13/actions" { fmt.Fprintln(w, `{"action":{"id": 123456, "status": "in-progress", "started_at": "2014-11-04T17:08:03Z", "resource_id": 13, "resource_type": "droplet"}}`) } + if r.URL.Path == "/v2/actions/123456" { + fmt.Fprintln(w, `{"action":{"id": 123456, "status": "completed", "started_at": "2014-11-04T17:08:03Z", "resource_id": 503, "resource_type": "droplet"}}`) + } })) defer fakeServer.Close() config.Set("iaas:digitalocean:url", fakeServer.URL)