Skip to content

Commit

Permalink
Compute V2: Don't fail when disassociating floating IP from the insta…
Browse files Browse the repository at this point in the history
…nce when it is already not associated. (#761)
  • Loading branch information
rnurgaliyev authored and jtopjian committed Jun 4, 2019
1 parent ae2c63b commit bf7e220
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"

"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingips"
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
)
Expand Down Expand Up @@ -203,7 +204,12 @@ func resourceComputeFloatingIPAssociateV2Delete(d *schema.ResourceData, meta int

err = floatingips.DisassociateInstance(computeClient, instanceId, disassociateOpts).ExtractErr()
if err != nil {
return CheckDeleted(d, err, "Error deleting openstack_compute_floatingip_associate_v2")
if _, ok := err.(gophercloud.ErrDefault409); ok {
// 409 is returned when floating ip address is not associated with an instance.
log.Printf("[DEBUG] openstack_compute_floatingip_associate_v2 %s is not associated with instance %s", d.Id(), instanceId)
} else {
return CheckDeleted(d, err, "Error deleting openstack_compute_floatingip_associate_v2")
}
}

return nil
Expand Down

0 comments on commit bf7e220

Please sign in to comment.