-
Notifications
You must be signed in to change notification settings - Fork 480
watcher: Fix K8sWatcher.FindPod #3409
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
Conversation
The K8sWatcher.FindPod method first tries to find a pod using index, then, if unsuccessful, falls back to walking the entire pods list. This fallback was incorrect - fix it. I'm not sure how often or if ever this code path was being hit in the wild - it would be hit only if the index got out-of-sync. It would be good to understand it, but for now let's just fix the bug. Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
✅ Deploy Preview for tetragon ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
I suppose walking the pod list might be applicable only if using In any case, the code looks clearly incorrect and no tests have caught it, so seems worth fixing. |
TestFindPodWalk would fail before the preceding commit fixing a bug in the fallback pod lookup. Signed-off-by: Anna Kapuscinska <anna@isovalent.com>
kkourt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, thanks!
I introduced the bug in: 175c591.
AFAICT, it was a typo and I ended using up the global variable (podIdx) instead of the argument (podID).
175c591#diff-29ab67ad2861533ba7cfc10ed9d527f12a57b27cae23c566d373d82027c8f4c6R167-R177
I guess at some point the argument was removed.
I'll mark this PR for backports.
The K8sWatcher.FindPod method first tries to find a pod using index, then, if
unsuccessful, falls back to walking the entire pods list. This fallback was
incorrect - fix it.
I'm not sure how often or if ever this code path was being hit in the wild - it
would be hit only if the index got out-of-sync. It would be good to understand
it, but for now let's just fix the bug.