provider/openstack: gophercloud migration: Accounting for 409 errors with LBaaSV2

This commit is contained in:
Joe Topjian 2016-10-16 02:57:41 +00:00
parent 1fce3ed9fd
commit 0253dbe51b
5 changed files with 47 additions and 7 deletions

View File

@ -299,6 +299,14 @@ func waitForListenerDelete(networkingClient *gophercloud.ServiceClient, listener
log.Printf("[DEBUG] Successfully deleted OpenStack LBaaSV2 listener %s", listenerID)
return listener, "DELETED", nil
}
if errCode, ok := err.(gophercloud.ErrUnexpectedResponseCode); ok {
if errCode.Actual == 409 {
log.Printf("[DEBUG] OpenStack LBaaSV2 listener (%s) is still in use.", listenerID)
return listener, "ACTIVE", nil
}
}
return listener, "ACTIVE", err
}

View File

@ -138,7 +138,7 @@ func resourceLoadBalancerV2Read(d *schema.ResourceData, meta interface{}) error
return CheckDeleted(d, err, "LoadBalancerV2")
}
log.Printf("[DEBUG] Retrieved OpenStack LoadBalancerV2 %s: %+v", d.Id(), lb)
log.Printf("[DEBUG] Retrieved OpenStack LBaaSV2 LoadBalancer %s: %+v", d.Id(), lb)
d.Set("name", lb.Name)
d.Set("description", lb.Description)
@ -199,7 +199,7 @@ func resourceLoadBalancerV2Delete(d *schema.ResourceData, meta interface{}) erro
_, err = stateConf.WaitForState()
if err != nil {
return fmt.Errorf("Error deleting OpenStack LB Pool: %s", err)
return fmt.Errorf("Error deleting OpenStack LBaaSV2 LoadBalancer: %s", err)
}
d.SetId("")
@ -213,7 +213,7 @@ func waitForLoadBalancerActive(networkingClient *gophercloud.ServiceClient, lbID
return nil, "", err
}
log.Printf("[DEBUG] OpenStack LoadBalancer: %+v", lb)
log.Printf("[DEBUG] OpenStack LBaaSV2 LoadBalancer: %+v", lb)
if lb.ProvisioningStatus == "ACTIVE" {
return lb, "ACTIVE", nil
}
@ -224,12 +224,12 @@ func waitForLoadBalancerActive(networkingClient *gophercloud.ServiceClient, lbID
func waitForLoadBalancerDelete(networkingClient *gophercloud.ServiceClient, lbID string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
log.Printf("[DEBUG] Attempting to delete OpenStack LoadBalancerV2 %s", lbID)
log.Printf("[DEBUG] Attempting to delete OpenStack LBaaSV2 LoadBalancer %s", lbID)
lb, err := loadbalancers.Get(networkingClient, lbID).Extract()
if err != nil {
if _, ok := err.(gophercloud.ErrDefault404); ok {
log.Printf("[DEBUG] Successfully deleted OpenStack LoadBalancerV2 %s", lbID)
log.Printf("[DEBUG] Successfully deleted OpenStack LBaaSV2 LoadBalancer %s", lbID)
return lb, "DELETED", nil
}
return lb, "ACTIVE", err
@ -239,13 +239,21 @@ func waitForLoadBalancerDelete(networkingClient *gophercloud.ServiceClient, lbID
err = loadbalancers.Delete(networkingClient, lbID).ExtractErr()
if err != nil {
if _, ok := err.(gophercloud.ErrDefault404); ok {
log.Printf("[DEBUG] Successfully deleted OpenStack LoadBalancerV2 %s", lbID)
log.Printf("[DEBUG] Successfully deleted OpenStack LBaaSV2 LoadBalancer %s", lbID)
return lb, "DELETED", nil
}
if errCode, ok := err.(gophercloud.ErrUnexpectedResponseCode); ok {
if errCode.Actual == 409 {
log.Printf("[DEBUG] OpenStack LBaaSV2 LoadBalancer (%s) is still in use.", lbID)
return lb, "ACTIVE", nil
}
}
return lb, "ACTIVE", err
}
log.Printf("[DEBUG] OpenStack LoadBalancerV2 %s still active.", lbID)
log.Printf("[DEBUG] OpenStack LBaaSV2 LoadBalancer (%s) still active.", lbID)
return lb, "ACTIVE", nil
}
}

View File

@ -257,6 +257,14 @@ func waitForMemberDelete(networkingClient *gophercloud.ServiceClient, poolID str
log.Printf("[DEBUG] Successfully deleted OpenStack LBaaSV2 Member %s", memberID)
return member, "DELETED", nil
}
if errCode, ok := err.(gophercloud.ErrUnexpectedResponseCode); ok {
if errCode.Actual == 409 {
log.Printf("[DEBUG] OpenStack LBaaSV2 Member (%s) is still in use.", memberID)
return member, "ACTIVE", nil
}
}
return member, "ACTIVE", err
}

View File

@ -272,6 +272,14 @@ func waitForMonitorDelete(networkingClient *gophercloud.ServiceClient, monitorID
log.Printf("[DEBUG] Successfully deleted OpenStack LBaaSV2 Monitor %s", monitorID)
return monitor, "DELETED", nil
}
if errCode, ok := err.(gophercloud.ErrUnexpectedResponseCode); ok {
if errCode.Actual == 409 {
log.Printf("[DEBUG] OpenStack LBaaSV2 Monitor (%s) is still in use.", monitorID)
return monitor, "ACTIVE", nil
}
}
return monitor, "ACTIVE", err
}

View File

@ -305,6 +305,14 @@ func waitForPoolDelete(networkingClient *gophercloud.ServiceClient, poolID strin
log.Printf("[DEBUG] Successfully deleted OpenStack LBaaSV2 Pool %s", poolID)
return pool, "DELETED", nil
}
if errCode, ok := err.(gophercloud.ErrUnexpectedResponseCode); ok {
if errCode.Actual == 409 {
log.Printf("[DEBUG] OpenStack LBaaSV2 Pool (%s) is still in use.", poolID)
return pool, "ACTIVE", nil
}
}
return pool, "ACTIVE", err
}