Commit b36cb27a authored by Florian Ludwig's avatar Florian Ludwig Committed by Joffrey F

openstack: don't fail when trying to delete non-existing keypair

Signed-off-by: Florian Ludwig's avatarFlorian Ludwig <[email protected]>
parent 7909ee37
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment