Skip to content

Commit

Permalink
Fixed IPAM full issue in certain cases
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Jan 19, 2024
1 parent 0667af0 commit 6efb303
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion pkg/agent/manager/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 6efb303

Please sign in to comment.