Skip to content

Commit

Permalink
ippool: gracefully exit with proper logs if ippool got exhausted
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Jun 25, 2024
1 parent 35db2de commit a732a2a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/agent/manager/gatewayapi/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func (gm *GatewayManager) createGateway(gw *v1.Gateway) error {
newIP, identIPAM := ipPool.GetNewIPAddr(GenKey(gw.Namespace, gw.Name), 0, "")
if newIP == nil {
klog.Error("gateway ip pool failure")
klog.Exit("kube-loxilb cant run optimally anymore")
return fmt.Errorf("failed to generate gateway address")
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/manager/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,7 @@ func (m *Manager) getIngressSvcPairs(service *corev1.Service, addrType string, l
newIP, identIPAM = ipPool.GetNewIPAddr(cacheKey, uint32(portNum), proto)
if newIP == nil {
klog.Errorf("failed to generate external IP. IP Pool is full")
klog.Exit("kube-loxilb cant run optimally anymore")
return nil, errors.New("failed to generate external IP. IP Pool is full"), hasExtIPAllocated
}
sp = SvcPair{newIP.String(), portNum, proto, true, false, identIPAM, true, port}
Expand Down Expand Up @@ -1505,6 +1506,7 @@ func (m *Manager) getIngressSecSvcPairs(service *corev1.Service, numSecondary in
rpool.ReturnIPAddr(sPairs[j].IPString, sPairs[j].IdentIPAM)
}
klog.Errorf("failed to generate external secondary IP. IP Pool is full")
klog.Exit("kube-loxilb cant run optimally anymore")
return nil, errors.New("failed to generate external secondary IP. IP Pool is full")
}
sp := SvcPair{newIP.String(), portNum, proto, true, false, identIPAM, true, port}
Expand Down

0 comments on commit a732a2a

Please sign in to comment.