Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
Remove node on Create error
Browse files Browse the repository at this point in the history
Signed-off-by: kayrus <kay.diam@gmail.com>
  • Loading branch information
kayrus committed Sep 24, 2019
1 parent 621b2a1 commit b8bb147
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,13 @@ func (d *Driver) GetState() (state.State, error) {
return state.None, nil
}

func (d *Driver) failedToCreate(err error) error {
if e := d.Remove(); e != nil {
return fmt.Errorf("%v: %v", err, e)
}
return err
}

func (d *Driver) Create() error {
if err := d.resolveIds(); err != nil {
return err
Expand All @@ -485,15 +492,15 @@ func (d *Driver) Create() error {
return err
}
if err := d.waitForInstanceActive(); err != nil {
return err
return d.failedToCreate(err)
}
if d.FloatingIpPool != "" {
if err := d.assignFloatingIP(); err != nil {
return err
return d.failedToCreate(err)
}
}
if err := d.lookForIPAddress(); err != nil {
return err
return d.failedToCreate(err)
}
return nil
}
Expand Down

0 comments on commit b8bb147

Please sign in to comment.