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
Bug 1829824: Remove dead member from LB pool. #612
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -411,3 +411,35 @@ func listOpenStackOctaviaProviders(client *gophercloud.ServiceClient) ([]provide | |
return providersList, nil | ||
} | ||
} | ||
|
||
// Iterate on pool members and check their address against provided list | ||
// addresses of current master/bootstrap nodes. Remove all surplus members, | ||
// which address doesn't exists on that list. | ||
func purgeOpenStackLbPoolMember(client *gophercloud.ServiceClient, poolId string, addresses []string) error { | ||
page, err := pools.ListMembers(client, poolId, nil).AllPages() | ||
if err != nil { | ||
return errors.Wrap(err, "failed to get LB member list") | ||
} | ||
|
||
members, err := pools.ExtractMembers(page) | ||
if err != nil { | ||
return errors.Wrap(err, "failed to extract LB members list") | ||
} | ||
|
||
for _, member := range members { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as we have already added the "new members", does it make sense to compare here members and addresses length first, and if the same assume members are already up to date? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems tempting, although it won't prevent us from making less Octavia calls, right? And this will ensure, that members addresses are the same as for nodes addresses (as it should be) :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I support @gryf here, we could miss kind of a failover of master VM. Regardless of if it's possible or not, it's almost no cost to a do full comparison. It's just golang makes it look long and clumsy. ;) |
||
found := false | ||
for _, address := range addresses { | ||
if address == member.Address { | ||
found = true | ||
break | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of using |
||
} | ||
} | ||
if !found { | ||
err = pools.DeleteMember(client, poolId, member.ID).ExtractErr() | ||
if err != nil { | ||
return errors.Wrap(err, "failed to delete LB member") | ||
} | ||
} | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for
make()
in that case, justvar addresses []string
to create a nil slice should be fine,append
will be fine with it.