Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit 759a30c

Browse files
author
FengyunPan
committed
Only register floatingIP for external loadbalancer service
If the user has provided the floating-ip options, then it's safe to assume they want (only) the floating-ip to be the ingress IP; if they have not provided floating-ip options, then the LB IP is the only relevant value. Fix #52566
1 parent f85051a commit 759a30c

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -869,10 +869,6 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(clusterName string, apiService *v1.Serv
869869
glog.V(2).Infof("Deleted obsolete listener: %s", listener.ID)
870870
}
871871

872-
status := &v1.LoadBalancerStatus{}
873-
874-
status.Ingress = []v1.LoadBalancerIngress{{IP: loadbalancer.VipAddress}}
875-
876872
portID := loadbalancer.VipPortID
877873
floatIP, err := getFloatingIPByPortID(lbaas.network, portID)
878874
if err != nil && err != ErrNotFound {
@@ -895,8 +891,13 @@ func (lbaas *LbaasV2) EnsureLoadBalancer(clusterName string, apiService *v1.Serv
895891
return nil, fmt.Errorf("Error creating LB floatingip %+v: %v", floatIPOpts, err)
896892
}
897893
}
894+
895+
status := &v1.LoadBalancerStatus{}
896+
898897
if floatIP != nil {
899-
status.Ingress = append(status.Ingress, v1.LoadBalancerIngress{IP: floatIP.FloatingIP})
898+
status.Ingress = []v1.LoadBalancerIngress{{IP: floatIP.FloatingIP}}
899+
} else {
900+
status.Ingress = []v1.LoadBalancerIngress{{IP: loadbalancer.VipAddress}}
900901
}
901902

902903
if lbaas.opts.ManageSecurityGroups {
@@ -1453,9 +1454,6 @@ func (lb *LbaasV1) EnsureLoadBalancer(clusterName string, apiService *v1.Service
14531454
}
14541455

14551456
status := &v1.LoadBalancerStatus{}
1456-
1457-
status.Ingress = []v1.LoadBalancerIngress{{IP: vip.Address}}
1458-
14591457
if floatingPool != "" && !internalAnnotation {
14601458
floatIPOpts := floatingips.CreateOpts{
14611459
FloatingNetworkID: floatingPool,
@@ -1472,7 +1470,9 @@ func (lb *LbaasV1) EnsureLoadBalancer(clusterName string, apiService *v1.Service
14721470
return nil, fmt.Errorf("Error creating floatingip for openstack load balancer %s: %v", name, err)
14731471
}
14741472

1475-
status.Ingress = append(status.Ingress, v1.LoadBalancerIngress{IP: floatIP.FloatingIP})
1473+
status.Ingress = []v1.LoadBalancerIngress{{IP: floatIP.FloatingIP}}
1474+
} else {
1475+
status.Ingress = []v1.LoadBalancerIngress{{IP: vip.Address}}
14761476
}
14771477

14781478
return status, nil

0 commit comments

Comments
 (0)