From 6efb303a90ba39fe311b4e4bf16f9897dfaf8563 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Fri, 19 Jan 2024 17:30:52 +0900 Subject: [PATCH] Fixed IPAM full issue in certain cases --- .../manager/loadbalancer/loadbalancer.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pkg/agent/manager/loadbalancer/loadbalancer.go b/pkg/agent/manager/loadbalancer/loadbalancer.go index 5a05399..672d753 100644 --- a/pkg/agent/manager/loadbalancer/loadbalancer.go +++ b/pkg/agent/manager/loadbalancer/loadbalancer.go @@ -640,6 +640,20 @@ func (m *Manager) addLoadBalancer(svc *corev1.Service) error { if delete { m.deleteLoadBalancer(svc.Namespace, svc.Name) } + if added { + for _, lb := range m.lbCache[cacheKey].LbModelList { + for idx := range ingSvcPairs { + ingSvcPair := &ingSvcPairs[idx] + if ingSvcPair.IPString == lb.LbModel.Service.ExternalIP && + ingSvcPair.Port == int32(lb.LbModel.Service.Port) && + ingSvcPair.Protocol == lb.LbModel.Service.Protocol { + ingSvcPair.InRange = lb.inRange + ingSvcPair.StaticIP = lb.staticIP + ingSvcPair.IdentIPAM = lb.IdentIPAM + } + } + } + } m.lbCache[cacheKey].LbModelList = nil if !hasExistingEIP { svc.Status.LoadBalancer.Ingress = nil @@ -1249,11 +1263,14 @@ func (m *Manager) DiscoverLoxiLBServices(loxiLBAliveCh chan *api.LoxiClient, lox // DNS lookup (not used now) // ips, err := net.LookupIP("loxilb-lb-service") ips, err := k8s.GetServiceEndPoints(m.kubeClient, "loxilb-lb-service", "kube-system") - klog.Infof("loxilb-service end-points: %v", ips) if err != nil { ips = []net.IP{} } + if len(ips) != len(m.LoxiClients) { + klog.Infof("loxilb-service end-points: %v", ips) + } + for _, v := range m.LoxiClients { v.Purge = true for _, ip := range ips {