Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR - Fixed service pair check #99

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions pkg/agent/manager/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,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
checkServicePortLoop:
for _, port := range service.Spec.Ports {
proto := strings.ToLower(string(port.Protocol))
portNum := port.Port
Expand All @@ -1161,18 +1162,12 @@ func (m *Manager) getIngressSvcPairs(service *corev1.Service, addrType string, l
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)
continue
continue checkServicePortLoop
}
}

newIP, identIPAM = ipPool.GetNewIPAddr(cacheKey, uint32(portNum), proto)
if newIP == nil {
// This is a safety code in case the service has the same port.
for _, s := range sPairs {
if s.Port == portNum && s.Protocol == proto {
continue
}
}
klog.Errorf("failed to generate external IP. IP Pool is full")
return nil, errors.New("failed to generate external IP. IP Pool is full"), hasExtIPAllocated
}
Expand Down
Loading