Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for ErrDefault500 when creating/deleting pool member #12664

Merged
merged 1 commit into from
Mar 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions builtin/providers/openstack/resource_openstack_lb_member_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,20 @@ func resourceMemberV2Create(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] Attempting to create LBaaSV2 member")
member, err = pools.CreateMember(networkingClient, poolID, createOpts).Extract()
if err != nil {
if errCode, ok := err.(gophercloud.ErrUnexpectedResponseCode); ok {
if errCode.Actual == 409 || errCode.Actual == 500 {
switch errCode := err.(type) {
case gophercloud.ErrDefault500:
log.Printf("[DEBUG] OpenStack LBaaSV2 member is still creating.")
return resource.RetryableError(err)
case gophercloud.ErrUnexpectedResponseCode:
if errCode.Actual == 409 {
log.Printf("[DEBUG] OpenStack LBaaSV2 member is still creating.")
return resource.RetryableError(err)
}

default:
return resource.NonRetryableError(err)
}
return resource.NonRetryableError(err)
}

return nil
})

Expand Down Expand Up @@ -271,19 +276,22 @@ func waitForMemberDelete(networkingClient *gophercloud.ServiceClient, poolID str
log.Printf("[DEBUG] Openstack LBaaSV2 Member: %+v", member)
err = pools.DeleteMember(networkingClient, poolID, memberID).ExtractErr()
if err != nil {
if _, ok := err.(gophercloud.ErrDefault404); ok {
switch errCode := err.(type) {
case gophercloud.ErrDefault404:
log.Printf("[DEBUG] Successfully deleted OpenStack LBaaSV2 Member %s", memberID)
return member, "DELETED", nil
}

if errCode, ok := err.(gophercloud.ErrUnexpectedResponseCode); ok {
case gophercloud.ErrDefault500:
log.Printf("[DEBUG] OpenStack LBaaSV2 Member (%s) is still in use.", memberID)
return member, "PENDING_DELETE", nil
case gophercloud.ErrUnexpectedResponseCode:
if errCode.Actual == 409 {
log.Printf("[DEBUG] OpenStack LBaaSV2 Member (%s) is still in use.", memberID)
return member, "PENDING_DELETE", nil
}
}

return member, "ACTIVE", err
default:
return member, "ACTIVE", err
}
}

log.Printf("[DEBUG] OpenStack LBaaSV2 Member %s still active.", memberID)
Expand Down