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

Added monitor-address and monitor-port to openstack_lb_member_v2 #1390

Merged
merged 9 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
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
54 changes: 54 additions & 0 deletions openstack/lb_v2_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,37 @@ func waitForLBV2Member(ctx context.Context, lbClient *gophercloud.ServiceClient,
return nil
}

func waitForLBV2OctaviaMember(ctx context.Context, lbClient *gophercloud.ServiceClient, parentPool *neutronpools.Pool, member *octaviapools.Member, target string, pending []string, timeout time.Duration) error {
log.Printf("[DEBUG] Waiting for member %s to become %s.", member.ID, target)

lbID, err := lbV2FindLBIDviaPool(lbClient, parentPool)
if err != nil {
return err
}

stateConf := &resource.StateChangeConf{
Target: []string{target},
Pending: pending,
Refresh: resourceLBV2OctaviaMemberRefreshFunc(lbClient, lbID, parentPool.ID, member),
Timeout: timeout,
Delay: 1 * time.Second,
MinTimeout: 1 * time.Second,
}

_, err = stateConf.WaitForStateContext(ctx)
if err != nil {
if _, ok := err.(gophercloud.ErrDefault404); ok {
if target == "DELETED" {
return nil
}
}

return fmt.Errorf("Error waiting for member %s to become %s: %s", member.ID, target, err)
}

return nil
}

func resourceLBV2MemberRefreshFunc(lbClient *gophercloud.ServiceClient, lbID string, poolID string, member *neutronpools.Member) resource.StateRefreshFunc {
if member.ProvisioningStatus != "" {
return func() (interface{}, string, error) {
Expand All @@ -706,6 +737,29 @@ func resourceLBV2MemberRefreshFunc(lbClient *gophercloud.ServiceClient, lbID str
return resourceLBV2LoadBalancerStatusRefreshFuncNeutron(lbClient, lbID, "member", member.ID, poolID)
}

func resourceLBV2OctaviaMemberRefreshFunc(lbClient *gophercloud.ServiceClient, lbID string, poolID string, member *octaviapools.Member) resource.StateRefreshFunc {
if member.ProvisioningStatus != "" {
return func() (interface{}, string, error) {
lb, status, err := resourceLBV2LoadBalancerRefreshFunc(lbClient, lbID)()
if err != nil {
return lb, status, err
}
if !strSliceContains(getLbSkipStatuses(), status) {
return lb, status, nil
}

member, err := neutronpools.GetMember(lbClient, poolID, member.ID).Extract()
if err != nil {
return nil, "", err
}

return member, member.ProvisioningStatus, nil
}
}

return resourceLBV2LoadBalancerStatusRefreshFuncNeutron(lbClient, lbID, "member", member.ID, poolID)
}

func waitForLBV2Monitor(ctx context.Context, lbClient *gophercloud.ServiceClient, parentPool *neutronpools.Pool, monitor *neutronmonitors.Monitor, target string, pending []string, timeout time.Duration) error {
log.Printf("[DEBUG] Waiting for openstack_lb_monitor_v2 %s to become %s.", monitor.ID, target)

Expand Down
Loading