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

Commit 7849325

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #52611 from FengyunPan/missing-floatingip
Automatic merge from submit-queue (batch tested with PRs 52751, 52898, 52633, 52611, 52609). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.. Fix missing floatingip when calling GetLoadBalancer() If user specify floating-network-id, a floatingip and a vip will be assigned to LoadBalancer service, So its status contains a floatingip and a vip, but GetLoadBalancer() only return vip. **Release note**: ```release-note GetLoadBalancer() only return floatingip when user specify floating-network-id, or return LB vip. ```
2 parents 83d1556 + e4d38f8 commit 7849325

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
@@ -538,7 +538,17 @@ func (lbaas *LbaasV2) GetLoadBalancer(clusterName string, service *v1.Service) (
538538
}
539539

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

543553
return status, true, err
544554
}
@@ -1289,7 +1299,16 @@ func (lb *LbaasV1) GetLoadBalancer(clusterName string, service *v1.Service) (*v1
12891299
}
12901300

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

12941313
return status, true, err
12951314
}

0 commit comments

Comments
 (0)