Skip to content

Commit

Permalink
openstack: don't fail when trying to delete non-existing keypair
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Ludwig <[email protected]>
  • Loading branch information
FlorianLudwig authored and shin- committed Sep 20, 2018
1 parent 7909ee3 commit b36cb27
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/openstack/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,15 @@ func (d *Driver) Remove() error {
if !d.ExistingKey {
log.Debug("deleting key pair...", map[string]string{"Name": d.KeyPairName})
if err := d.client.DeleteKeyPair(d, d.KeyPairName); err != nil {
return err
if gopherErr, ok := err.(*gophercloud.UnexpectedResponseCodeError); ok {
if gopherErr.Actual == http.StatusNotFound {
log.Warn("Keypair already deleted")
} else {
return err
}
} else {
return err
}
}
}
return nil
Expand Down

0 comments on commit b36cb27

Please sign in to comment.