mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
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. ```
This commit is contained in:
commit
1e36480492
@ -538,7 +538,17 @@ func (lbaas *LbaasV2) GetLoadBalancer(clusterName string, service *v1.Service) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
status := &v1.LoadBalancerStatus{}
|
status := &v1.LoadBalancerStatus{}
|
||||||
|
|
||||||
|
portID := loadbalancer.VipPortID
|
||||||
|
if portID != "" {
|
||||||
|
floatIP, err := getFloatingIPByPortID(lbaas.network, portID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, false, fmt.Errorf("Error getting floating ip for port %s: %v", portID, err)
|
||||||
|
}
|
||||||
|
status.Ingress = []v1.LoadBalancerIngress{{IP: floatIP.FloatingIP}}
|
||||||
|
} else {
|
||||||
status.Ingress = []v1.LoadBalancerIngress{{IP: loadbalancer.VipAddress}}
|
status.Ingress = []v1.LoadBalancerIngress{{IP: loadbalancer.VipAddress}}
|
||||||
|
}
|
||||||
|
|
||||||
return status, true, err
|
return status, true, err
|
||||||
}
|
}
|
||||||
@ -1289,7 +1299,16 @@ func (lb *LbaasV1) GetLoadBalancer(clusterName string, service *v1.Service) (*v1
|
|||||||
}
|
}
|
||||||
|
|
||||||
status := &v1.LoadBalancerStatus{}
|
status := &v1.LoadBalancerStatus{}
|
||||||
|
|
||||||
|
if vip.PortID != "" {
|
||||||
|
floatingIP, err := getFloatingIPByPortID(lb.network, vip.PortID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, false, fmt.Errorf("Error getting floating ip for port %s: %v", vip.PortID, err)
|
||||||
|
}
|
||||||
|
status.Ingress = []v1.LoadBalancerIngress{{IP: floatingIP.FloatingIP}}
|
||||||
|
} else {
|
||||||
status.Ingress = []v1.LoadBalancerIngress{{IP: vip.Address}}
|
status.Ingress = []v1.LoadBalancerIngress{{IP: vip.Address}}
|
||||||
|
}
|
||||||
|
|
||||||
return status, true, err
|
return status, true, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user