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

FindPidByPodContainer unreliable #174

Closed
michaelgugino opened this issue Oct 1, 2021 · 3 comments · Fixed by #205 · May be fixed by #207
Closed

FindPidByPodContainer unreliable #174

michaelgugino opened this issue Oct 1, 2021 · 3 comments · Fixed by #205 · May be fixed by #207

Comments

@michaelgugino
Copy link

needle := path.Join(podUID, containerID)

This code makes too many assumptions about what the file paths will look like.

Actual mount results on my cluster look like /kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod30cea2cf_1b80_4807_abad_d81453e199c5.slice/crio-a8077b08a56c0c6e33d6716557d882ac940cb09475c50372e22e84c40d0733f2.scope

Additionally, the following agruments get passed to the job container
--pod-uid=30cea2cf-1b80-4807-abad-d81453e199c5 --container-id=cri-o://a8077b08a56c0c6e33d6716557d882ac940cb09475c50372e22e84c40d0733f2

We need to also trim the cri-o:// prefix. The pod UID seems to replace - with _ so that is another issue.

This project works for me: https://github.com/yahoo/kubectl-flame/blob/master/agent/utils/process.go#L35

@dalehamel
Copy link
Member

Hi there, we've never tested with cri-o before so thanks for flagging this. Thanks also for linking some more generic code.

@DrAuYueng
Copy link

DrAuYueng commented May 24, 2024

@dalehamel If containerd is used as the CRI runtime, the mount info looks like:

/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod40934a46_d409_4f4a_bb8b_1ec0b0436320.slice/cri-containerd-afc114c69e71f18166abd63715398d7daa763c69a6454f71157272ab0bdca783.scope

The generic code would be better like this:

if strings.Contains(root, podUID) && strings.Contains(root, containerID) {
					return &dname, nil
				}

@DrAuYueng
Copy link

@dalehamel I submitted a PR(#207 ) to fix this, can you take a look?

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