Merge pull request #10875 from jtopjian/openstack-lbv2-member-409

provider/openstack: 409 Response on Member Create
This commit is contained in:
Joe Topjian 2016-12-27 21:44:28 -07:00 committed by GitHub
commit 91a332b5b5
1 changed files with 20 additions and 2 deletions

View File

@ -117,7 +117,25 @@ func resourceMemberV2Create(d *schema.ResourceData, meta interface{}) error {
poolID := d.Get("pool_id").(string)
log.Printf("[DEBUG] Create Options: %#v", createOpts)
member, err := pools.CreateMember(networkingClient, poolID, createOpts).Extract()
var member *pools.Member
err = resource.Retry(10*time.Minute, func() *resource.RetryError {
var err 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 {
log.Printf("[DEBUG] OpenStack LBaaSV2 member is still creating.")
return resource.RetryableError(err)
}
}
return resource.NonRetryableError(err)
}
return nil
})
if err != nil {
return fmt.Errorf("Error creating OpenStack LBaaSV2 member: %s", err)
}
@ -261,7 +279,7 @@ func waitForMemberDelete(networkingClient *gophercloud.ServiceClient, poolID str
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, "PENDING_DELETE", nil
}
}