diff --git a/pkg/agent/manager/gatewayapi/const.go b/pkg/agent/manager/gatewayapi/const.go index 0af18f2..63b9d6f 100644 --- a/pkg/agent/manager/gatewayapi/const.go +++ b/pkg/agent/manager/gatewayapi/const.go @@ -23,7 +23,7 @@ const ( minRetryDelay = 2 * time.Second maxRetryDelay = 120 * time.Second defaultWorkers = 4 - contextTimeout = 5 * time.Second + contextTimeout = 30 * time.Second implementation = "kube-loxilb" finalizer = "loxilb.io" ) diff --git a/pkg/agent/manager/gatewayapi/gateway.go b/pkg/agent/manager/gatewayapi/gateway.go index ad1e02d..0a75e9b 100644 --- a/pkg/agent/manager/gatewayapi/gateway.go +++ b/pkg/agent/manager/gatewayapi/gateway.go @@ -78,7 +78,7 @@ func NewGatewayManager( gatewayLister: gatewayInformer.Lister(), gatewayListerSynced: gatewayInformer.Informer().HasSynced, - queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(minRetryDelay, maxRetryDelay), "gatewayClass"), + queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(minRetryDelay, maxRetryDelay), "gateway"), } manager.gatewayInformer.Informer().AddEventHandler( diff --git a/pkg/agent/manager/gatewayapi/tcproute.go b/pkg/agent/manager/gatewayapi/tcproute.go index e61381b..ab18767 100644 --- a/pkg/agent/manager/gatewayapi/tcproute.go +++ b/pkg/agent/manager/gatewayapi/tcproute.go @@ -82,7 +82,7 @@ func NewTCPRouteManager( tcpRouteLister: tcpRouteInformer.Lister(), tcpRouteListerSynced: tcpRouteInformer.Informer().HasSynced, - queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(minRetryDelay, maxRetryDelay), "gatewayClass"), + queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(minRetryDelay, maxRetryDelay), "tcpRoute"), } manager.tcpRouteInformer.Informer().AddEventHandler( diff --git a/pkg/agent/manager/gatewayapi/udproute.go b/pkg/agent/manager/gatewayapi/udproute.go index fa74aec..0e3feab 100644 --- a/pkg/agent/manager/gatewayapi/udproute.go +++ b/pkg/agent/manager/gatewayapi/udproute.go @@ -82,7 +82,7 @@ func NewUDPRouteManager( udpRouteLister: udpRouteInformer.Lister(), udpRouteListerSynced: udpRouteInformer.Informer().HasSynced, - queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(minRetryDelay, maxRetryDelay), "gatewayClass"), + queue: workqueue.NewNamedRateLimitingQueue(workqueue.NewItemExponentialFailureRateLimiter(minRetryDelay, maxRetryDelay), "udpRoute"), } manager.udpRouteInformer.Informer().AddEventHandler( diff --git a/pkg/agent/manager/loadbalancer/loadbalancer.go b/pkg/agent/manager/loadbalancer/loadbalancer.go index 7955c77..82857eb 100644 --- a/pkg/agent/manager/loadbalancer/loadbalancer.go +++ b/pkg/agent/manager/loadbalancer/loadbalancer.go @@ -1373,21 +1373,25 @@ func (m *Manager) getIngressSvcPairs(service *corev1.Service, addrType string, l // k8s service has ingress IP already if len(inSPairs) >= 1 { + klog.V(4).Infof("getIngressSvcPairs: service %s has servicePairs: %v", cacheKey, inSPairs) + klog.V(4).Infof("getIngressSvcPairs: service %s has externalIP: %v", cacheKey, service.Status.LoadBalancer.Ingress) checkSvcPortLoop: for _, inSPair := range inSPairs { hasExtIPAllocated = true for _, sp := range lbCacheEntry.LbServicePairs { if GenSPKey(inSPair.IPString, uint16(inSPair.Port), inSPair.Protocol) == GenSPKey(sp.ExternalIP, sp.Port, sp.Protocol) { - sp := SvcPair{sp.ExternalIP, int32(sp.Port), sp.Protocol, sp.InRange, sp.StaticIP, sp.IdentIPAM, false, inSPair.K8sSvcPort} - sPairs = append(sPairs, sp) + oldsp := SvcPair{sp.ExternalIP, int32(sp.Port), sp.Protocol, sp.InRange, sp.StaticIP, sp.IdentIPAM, false, inSPair.K8sSvcPort} + sPairs = append(sPairs, oldsp) + klog.V(4).Infof("getIngressSvcPairs: LB cache %s already has servicePairs: %v", cacheKey, sp) continue checkSvcPortLoop } } inRange, _, identStr := ipPool.CheckAndReserveIP(inSPair.IPString, cacheKey, uint32(inSPair.Port), inSPair.Protocol) - sp := SvcPair{inSPair.IPString, inSPair.Port, inSPair.Protocol, inRange, true, identStr, true, inSPair.K8sSvcPort} - sPairs = append(sPairs, sp) + newsp := SvcPair{inSPair.IPString, inSPair.Port, inSPair.Protocol, inRange, true, identStr, true, inSPair.K8sSvcPort} + klog.V(4).Infof("getIngressSvcPairs: LB cache %s is added servicePairs: %v", cacheKey, newsp) + sPairs = append(sPairs, newsp) } } @@ -1396,7 +1400,7 @@ func (m *Manager) getIngressSvcPairs(service *corev1.Service, addrType string, l // If hasExtIPAllocated is false, that means k8s service has no ingress IP if !hasExtIPAllocated { - var sp SvcPair + klog.V(4).Infof("getIngressSvcPairs: service %s has no externalIP: %v", cacheKey, service.Status.LoadBalancer.Ingress) checkServicePortLoop: for _, port := range service.Spec.Ports { proto := strings.ToLower(string(port.Protocol)) @@ -1404,23 +1408,27 @@ func (m *Manager) getIngressSvcPairs(service *corev1.Service, addrType string, l for _, sp := range lbCacheEntry.LbServicePairs { if sp.Port == uint16(portNum) && proto == sp.Protocol { - sp := SvcPair{sp.ExternalIP, int32(sp.Port), sp.Protocol, sp.InRange, sp.StaticIP, sp.IdentIPAM, false, port} - sPairs = append(sPairs, sp) + oldsp := SvcPair{sp.ExternalIP, int32(sp.Port), sp.Protocol, sp.InRange, sp.StaticIP, sp.IdentIPAM, false, port} + sPairs = append(sPairs, oldsp) + klog.V(4).Infof("getIngressSvcPairs: LB cache %s already has servicePairs: %v", cacheKey, sp) continue checkServicePortLoop } } newIP, identIPAM = ipPool.GetNewIPAddr(cacheKey, uint32(portNum), proto) if newIP == nil { - klog.Errorf("failed to generate external IP. IP Pool is full") + errMsg := fmt.Sprintf("failed to generate external IP. %s:%d:%s already used for %s", cacheKey, portNum, proto, identIPAM) + klog.Errorf(errMsg) klog.Exit("kube-loxilb cant run optimally anymore") - return nil, errors.New("failed to generate external IP. IP Pool is full"), hasExtIPAllocated + return nil, errors.New(errMsg), hasExtIPAllocated } - sp = SvcPair{newIP.String(), portNum, proto, true, false, identIPAM, true, port} - sPairs = append(sPairs, sp) + + klog.V(4).Infof("getIngressSvcPairs: service %s is generated new externalIP: %s", cacheKey, newIP.String()) + + newsp := SvcPair{newIP.String(), portNum, proto, true, false, identIPAM, true, port} + sPairs = append(sPairs, newsp) } } - //klog.Infof("Spairs: %v", sPairs) return sPairs, nil, hasExtIPAllocated } @@ -1493,8 +1501,8 @@ func (m *Manager) getIngressSecSvcPairs(service *corev1.Service, numSecondary in for _, sp := range lbCacheEntry.LbServicePairs { if sp.Port == uint16(portNum) && proto == sp.Protocol { - sp := SvcPair{sp.ExternalIP, int32(sp.Port), sp.Protocol, sp.InRange, sp.StaticIP, sp.IdentIPAM, false, port} - sPairs = append(sPairs, sp) + oldsp := SvcPair{sp.ExternalIP, int32(sp.Port), sp.Protocol, sp.InRange, sp.StaticIP, sp.IdentIPAM, false, port} + sPairs = append(sPairs, oldsp) continue checkServicePortLoop } } @@ -1505,12 +1513,13 @@ func (m *Manager) getIngressSecSvcPairs(service *corev1.Service, numSecondary in rpool := sipPools[j] rpool.ReturnIPAddr(sPairs[j].IPString, sPairs[j].IdentIPAM) } - klog.Errorf("failed to generate external secondary IP. IP Pool is full") + errMsg := fmt.Sprintf("failed to generate secondary external IP. %s:%d:%s already used for %s", cacheKey, portNum, proto, identIPAM) + klog.Errorf(errMsg) klog.Exit("kube-loxilb cant run optimally anymore") - return nil, errors.New("failed to generate external secondary IP. IP Pool is full") + return nil, errors.New(errMsg) } - sp := SvcPair{newIP.String(), portNum, proto, true, false, identIPAM, true, port} - sPairs = append(sPairs, sp) + newsp := SvcPair{newIP.String(), portNum, proto, true, false, identIPAM, true, port} + sPairs = append(sPairs, newsp) } } diff --git a/pkg/api/lb.go b/pkg/api/lb.go index 60c0aba..c73b299 100644 --- a/pkg/api/lb.go +++ b/pkg/api/lb.go @@ -71,6 +71,7 @@ type LoadBalancerService struct { ProbeResp string `json:"proberesp"` ProbeRetries int32 `json:"probeRetries,omitempty"` ProbeTimeout uint32 `json:"probeTimeout,omitempty"` + Security int32 `json:"security,omitempty"` Name string `json:"name,omitempty"` Oper LbOP `json:"oper,omitempty"` }