Skip to content

Commit

Permalink
Merge pull request #508 from MaysaMacedo/no-lb-creation-upon-upgrade
Browse files Browse the repository at this point in the history
Bug 1808498: Ensure no API LB recreation happens upon Octavia upgrade
  • Loading branch information
openshift-merge-robot committed Mar 4, 2020
2 parents 161c3d7 + a432dde commit 94229e1
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/platform/openstack/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,37 @@ func ensureOpenStackLb(client *gophercloud.ServiceClient, name, vipAddress, vipS
if err != nil {
return "", errors.Wrap(err, "failed to extract LB list")
}

if len(lbs) == 0 && octaviaTagSupport {
// Attempt to retrieve API load balancer with description tagging
// to avoid another load balancer creation upon Octavia upgrade.
opts := loadbalancers.ListOpts{
Name: name,
VipAddress: vipAddress,
VipSubnetID: vipSubnetId,
Description: tag,
}
page, err = loadbalancers.List(client, opts).AllPages()
if err != nil {
return "", errors.Wrap(err, "failed to get LB list")
}
lbs, err = loadbalancers.ExtractLoadBalancers(page)
if err != nil {
return "", errors.Wrap(err, "failed to extract LB list")
}
if len(lbs) == 1 {
log.Printf("Tagging existing loadbalancer API %s", lbs[0].ID)
tags := []string{tag}
updateOpts := loadbalancers.UpdateOpts{
Tags: &tags,
}
_, err := loadbalancers.Update(client, lbs[0].ID, updateOpts).Extract()
if err != nil {
return "", errors.Wrap(err, "failed to update LB")
}
}
}

if len(lbs) > 1 {
return "", errors.Errorf("found multiple LB matching name %s, tag %s, cannot proceed", name, tag)
} else if len(lbs) == 1 {
Expand Down

0 comments on commit 94229e1

Please sign in to comment.