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

Commit e4d38f8

Browse files
author
FengyunPan
committed
Fix missing floatingip when calling GetLoadBalancer()
If user specify floating-network-id, a floatingip be assigned to LoadBalancer service, So its status contains a floatingip, but GetLoadBalancer() only return vip.
1 parent f85051a commit e4d38f8

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

pkg/cloudprovider/providers/openstack/openstack_loadbalancer.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,17 @@ func (lbaas *LbaasV2) GetLoadBalancer(clusterName string, service *v1.Service) (
536536
}
537537

538538
status := &v1.LoadBalancerStatus{}
539-
status.Ingress = []v1.LoadBalancerIngress{{IP: loadbalancer.VipAddress}}
539+
540+
portID := loadbalancer.VipPortID
541+
if portID != "" {
542+
floatIP, err := getFloatingIPByPortID(lbaas.network, portID)
543+
if err != nil {
544+
return nil, false, fmt.Errorf("Error getting floating ip for port %s: %v", portID, err)
545+
}
546+
status.Ingress = []v1.LoadBalancerIngress{{IP: floatIP.FloatingIP}}
547+
} else {
548+
status.Ingress = []v1.LoadBalancerIngress{{IP: loadbalancer.VipAddress}}
549+
}
540550

541551
return status, true, err
542552
}
@@ -1287,7 +1297,16 @@ func (lb *LbaasV1) GetLoadBalancer(clusterName string, service *v1.Service) (*v1
12871297
}
12881298

12891299
status := &v1.LoadBalancerStatus{}
1290-
status.Ingress = []v1.LoadBalancerIngress{{IP: vip.Address}}
1300+
1301+
if vip.PortID != "" {
1302+
floatingIP, err := getFloatingIPByPortID(lb.network, vip.PortID)
1303+
if err != nil {
1304+
return nil, false, fmt.Errorf("Error getting floating ip for port %s: %v", vip.PortID, err)
1305+
}
1306+
status.Ingress = []v1.LoadBalancerIngress{{IP: floatingIP.FloatingIP}}
1307+
} else {
1308+
status.Ingress = []v1.LoadBalancerIngress{{IP: vip.Address}}
1309+
}
12911310

12921311
return status, true, err
12931312
}

0 commit comments

Comments
 (0)