provider/openstack: 409 Response on Member Create

This commit accounts for a 409 response when a LBaaS v2 member is
being created. Rather than error out, this should be considered a
pending state.
This commit is contained in:
Joe Topjian 2016-12-21 02:24:26 +00:00
parent a45d2e5289
commit b2417ce880
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
}
}