Skip to content
Open
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
19 changes: 13 additions & 6 deletions pkg/openstack/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1695,13 +1695,20 @@ func (lbaas *LbaasV2) ensureOctaviaLoadBalancer(ctx context.Context, clusterName
}

// Here we test for a clusterName that could have had changed in the deployment.
// Only rename when the LB was originally created for this Service (i.e. the
// namespace and service name components match). Without this guard, a shared
// LB from a different cluster gets incorrectly renamed.
if lbHasOldClusterName(loadbalancer, clusterName) {
msg := "Loadbalancer %s has a name of %s with incorrect cluster-name component. Renaming it to %s."
klog.Infof(msg, loadbalancer.ID, loadbalancer.Name, lbName)
lbaas.eventRecorder.Eventf(service, corev1.EventTypeWarning, eventLBRename, msg, loadbalancer.ID, loadbalancer.Name, lbName)
loadbalancer, err = renameLoadBalancer(ctx, lbaas.lb, loadbalancer, lbName, clusterName)
if err != nil {
return nil, fmt.Errorf("failed to update load balancer %s with an updated name: %w", svcConf.lbID, err)
oldClusterName := getClusterName("", loadbalancer.Name)
expectedOldName := cpoutil.Sprintf255(lbFormat, servicePrefix, oldClusterName, service.Namespace, service.Name)
if loadbalancer.Name == expectedOldName {
msg := "Loadbalancer %s has a name of %s with incorrect cluster-name component. Renaming it to %s."
klog.Infof(msg, loadbalancer.ID, loadbalancer.Name, lbName)
lbaas.eventRecorder.Eventf(service, corev1.EventTypeWarning, eventLBRename, msg, loadbalancer.ID, loadbalancer.Name, lbName)
loadbalancer, err = renameLoadBalancer(ctx, lbaas.lb, loadbalancer, lbName, clusterName)
if err != nil {
return nil, fmt.Errorf("failed to update load balancer %s with an updated name: %w", svcConf.lbID, err)
}
}
}

Expand Down