Skip to content

Commit

Permalink
watcher: Fix K8sWatcher.FindPod
Browse files Browse the repository at this point in the history
This looks like a bug, but I'm not sure what are the implications yet...

Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
  • Loading branch information
lambdanis committed Feb 17, 2025
1 parent 6f9a8b7 commit 01924ed
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/watcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,16 @@ func (watcher *K8sWatcher) FindPod(podID string) (*corev1.Pod, error) {
}

allPods := podInformer.GetStore().List()
if pod, ok := findPod(allPods); ok {
if pod, ok := findPod(podID, allPods); ok {
return pod, nil
}
return nil, fmt.Errorf("unable to find pod with ID %s (index pods=%d all pods=%d)", podID, len(objs), len(allPods))
}

func findPod(pods []interface{}) (*corev1.Pod, bool) {
func findPod(podID string, pods []interface{}) (*corev1.Pod, bool) {
for i := range pods {
if pod, ok := pods[i].(*corev1.Pod); ok {
if pod.UID == podIdx {
if string(pod.UID) == podID {
return pod, true
}
}
Expand Down

0 comments on commit 01924ed

Please sign in to comment.