Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Feb 17, 2025

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.

@ghost ghost added the release-note/bug This PR fixes an issue in a previous release of Tetragon. label Feb 17, 2025
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>
@ghost ghost marked this pull request as ready for review March 20, 2025 16:49
@ghost ghost self-requested a review as a code owner March 20, 2025 16:49
@ghost ghost requested a review from will-isovalent March 20, 2025 16:49
@netlify
Copy link

netlify bot commented Mar 20, 2025

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit ca0b5a5
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/67dc470c263eba0008c92daa
😎 Deploy Preview https://deploy-preview-3409--tetragon.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ghost
Copy link
Author

ghost commented Mar 20, 2025

I suppose walking the pod list might be applicable only if using FakeK8sWatcher? In such case we could remove the fallback from K8sWatcher.FindPod...

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>
Copy link
Contributor

@kkourt kkourt left a 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.

@kkourt kkourt added needs-backport/1.2 This PR needs backporting to v1.2 needs-backport/1.3 This PR needs backporting to v1.3 labels Mar 21, 2025
@kkourt kkourt merged commit 4181dbb into cilium:main Mar 21, 2025
41 checks passed
@ghost ghost added backport-pending/1.2 The backport for this PR is in progress. backport-pending/1.3 The backport for this PR is in progress. and removed needs-backport/1.2 This PR needs backporting to v1.2 needs-backport/1.3 This PR needs backporting to v1.3 labels Mar 21, 2025
@ghost ghost added backport-done/1.3 PR backport done. backport-done/1.2 PR backport done. and removed backport-pending/1.3 The backport for this PR is in progress. backport-pending/1.2 The backport for this PR is in progress. labels Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-done/1.2 PR backport done. backport-done/1.3 PR backport done. release-note/bug This PR fixes an issue in a previous release of Tetragon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant