providers/digitalocean: restart droplet in failed resize
This commit is contained in:
parent
8679ae6a2f
commit
2fe6f2e2b1
|
@ -112,6 +112,10 @@ func resource_digitalocean_droplet_update(
|
||||||
err = client.Resize(rs.ID, attr.New)
|
err = client.Resize(rs.ID, attr.New)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
newErr := power_on_and_wait(rs.ID, client)
|
||||||
|
if newErr != nil {
|
||||||
|
return rs, newErr
|
||||||
|
}
|
||||||
return rs, err
|
return rs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +124,10 @@ func resource_digitalocean_droplet_update(
|
||||||
rs.ID, attr.New, []string{"", attr.Old}, "size", client)
|
rs.ID, attr.New, []string{"", attr.Old}, "size", client)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
newErr := power_on_and_wait(rs.ID, client)
|
||||||
|
if newErr != nil {
|
||||||
|
return rs, newErr
|
||||||
|
}
|
||||||
return s, err
|
return s, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,3 +384,22 @@ func new_droplet_state_refresh_func(id string, attribute string, client *digital
|
||||||
return nil, "", nil
|
return nil, "", nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Powers on the droplet and waits for it to be active
|
||||||
|
func power_on_and_wait(id string, client *digitalocean.Client) error {
|
||||||
|
err := client.PowerOn(id)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for power off
|
||||||
|
_, err = WaitForDropletAttribute(
|
||||||
|
id, "active", []string{"off"}, "status", client)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue