Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit b36cb27

Browse files
FlorianLudwigshin-
authored andcommitted
openstack: don't fail when trying to delete non-existing keypair
Signed-off-by: Florian Ludwig <f.ludwig@greyrook.com>
1 parent 7909ee3 commit b36cb27

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎drivers/openstack/openstack.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,15 @@ func (d *Driver) Remove() error {
473473
if !d.ExistingKey {
474474
log.Debug("deleting key pair...", map[string]string{"Name": d.KeyPairName})
475475
if err := d.client.DeleteKeyPair(d, d.KeyPairName); err != nil {
476-
return err
476+
if gopherErr, ok := err.(*gophercloud.UnexpectedResponseCodeError); ok {
477+
if gopherErr.Actual == http.StatusNotFound {
478+
log.Warn("Keypair already deleted")
479+
} else {
480+
return err
481+
}
482+
} else {
483+
return err
484+
}
477485
}
478486
}
479487
return nil

0 commit comments

Comments
 (0)