Skip to content

Commit

Permalink
fix(NSC): compare all pod IPs for endpoint check
Browse files Browse the repository at this point in the history
Don't just compare the primary IP according to k8s, but all IPs that the
pod contains.
  • Loading branch information
aauren committed Oct 7, 2023
1 parent 9f23cf5 commit 9abe20d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/controllers/proxy/network_services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,8 +850,10 @@ func hasActiveEndpoints(endpoints []endpointSliceInfo) bool {
func (nsc *NetworkServicesController) getPodObjectForEndpoint(endpointIP string) (*v1.Pod, error) {
for _, obj := range nsc.podLister.List() {
pod := obj.(*v1.Pod)
if strings.Compare(pod.Status.PodIP, endpointIP) == 0 {
return pod, nil
for _, ip := range pod.Status.PodIPs {
if strings.Compare(ip.IP, endpointIP) == 0 {
return pod, nil
}
}
}
return nil, errors.New("Failed to find pod with ip " + endpointIP)
Expand Down

0 comments on commit 9abe20d

Please sign in to comment.