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

Parse container id #207

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DrAuYueng
Copy link

Fixes #174 .

needle := path.Join(podUID, containerID)
if strings.Contains(root, needle) {
// EG: /kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod40934a46_d409_4f4a_bb8b_1ec0b0436320.slice/cri-containerd-afc114c69e71f18166abd63715398d7daa763c69a6454f71157272ab0bdca783.scope
if strings.Contains(root, podUID) && strings.Contains(root, containerID) {
Copy link
Contributor

@cakemanny cakemanny Jun 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which setup have you tested this with?
I also found that I needed to fix this when working on my PR: https://github.com/iovisor/kubectl-trace/pull/205/files#diff-3fc753f2ae105df1b499d656901818c3aae006a40a0d807d4871520a19d612a5

I found podUID contained -s in place of _s in the cgroup name.
i.e. in your example, I'd expect podUID to be "40934a46-d409-4f4a-bb8b-1ec0b0436320".
It looks like that was also mentioned in the description of #174 . (I was using kind v0.19.x on an ubuntu 22.04 VM, not sure the host matters though)

You could also feel inspired to add a unit test like I did..., but I'm not from the iovisor group, just a fellow attempting contributor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FindPidByPodContainer unreliable
2 participants