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

metadata: Fix metadata association problems concerning children processes #1232

Merged
merged 12 commits into from
Jan 19, 2023

Conversation

kakkoyun
Copy link
Member

@kakkoyun kakkoyun commented Jan 18, 2023

Fixes #1157

In this PR, to associate the metadata for the container to all processes in the container, we traverse all the PID namespaces (type: pid and pid_for_children) and group the process by the PID namespace. And then, as a further check, we check if they belong to the same groups (CPU or systemd). You can see the result of the association in the below screenshots.

This is a stopgap solution to be able to release a patch. A long-term, cleaner solution will be provided for the main branch. It needs a little more time.

After merging this, we can release a patch version.

Test Output

CleanShot 2023-01-18 at 18 35 48@2x

CleanShot 2023-01-18 at 18 32 59@2x

xref: https://kubernetes.io/docs/tasks/configure-pod-container/share-process-namespace/

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
@kakkoyun kakkoyun requested a review from a team as a code owner January 18, 2023 18:03
@kakkoyun
Copy link
Member Author

I officially declare my dislike of @pre-commit bot.
These auto-fixes are not productive.

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Copy link
Member

@maxbrunet maxbrunet left a comment

Choose a reason for hiding this comment

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

LGTM!


for _, namespace := range namespaces {
for _, inode := range nsInodes {
if namespace.Inode == inode && ccg.Path == cg.Path {
Copy link
Member

Choose a reason for hiding this comment

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

Nicely done! This should handle the case where containers share the same PID namespace

https://kubernetes.io/docs/tasks/configure-pod-container/share-process-namespace/

@@ -1,4 +1,4 @@
Copyright 2023 The Parca Authors
Copyright 2022 The Parca Authors
Copy link
Member

Choose a reason for hiding this comment

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

Yes, let's keep 2022 for now, the check is not flexible, here is the related issue Lucas-C/pre-commit-hooks#23 and someone opened a PR today!

@@ -1,4 +1,6 @@
// Copyright 2022 The Parca Authors
// TODO: This license is not consistent with license used in the project.
// Delete the inconsistent license and above line and rerun pre-commit to insert a good license.
Copy link
Member

Choose a reason for hiding this comment

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

Never fight a bot, it does not get tired 😆

The TODOs from 2022 → 2023 → 2022 pass would need to be cleaned up, so the check can succeed

The autofix was added recently to assist contributors with style nits, if the majority thinks it does not help, I have no strong opinion for keeping it, although it only seems to require a bit of tuning/fixing here

Copy link
Member Author

Choose a reason for hiding this comment

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

I wrote those when I was frustrated with the bot. We can keep it if we tune it.
Let's give it more chance ☺️

I don't want them to fight against me when Skynet has risen.

Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
Copy link
Member

@brancz brancz left a comment

Choose a reason for hiding this comment

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

lgtm, unless we have reports of this not working for users (or too expensive to perform) I'm not even convinced we need anything else

Copy link
Contributor

@javierhonduco javierhonduco left a comment

Choose a reason for hiding this comment

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

LGTM! Let's check on the demo environment to ensure that it's working as expected.

Two things that I thought of but that can be done later on:

  • Was this tested in minikube, too? Just in case the groups v1 env there could bite us.
  • Once our plates are less full perhaps we should add tests for `pkg/cgroup/cgroup.go and other of the files that handle this logic.

for pid := range adjPIDs {
pids = append(pids, pid)
}
sort.Ints(pids)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to sort them?

@kakkoyun
Copy link
Member Author

lgtm, unless we have reports of this not working for users (or too expensive to perform) I'm not even convinced we need anything else

The operation only gets triggered when Kubernetes reschedule the pod/container. So in regular operation, it's very infrequent.

@kakkoyun
Copy link
Member Author

  • Once our plates are less full perhaps we should add tests for `pkg/cgroup/cgroup.go and other of the files that handle this logic.

I agree 👍 To note, none of those functions are new. Logically nothing has changed.

  • Was this tested in minikube, too? Just in case the groups v1 env there could bite us.

The screenshots from the tests that I have conducted on Minikube.

@kakkoyun kakkoyun merged commit 0e42468 into parca-dev:release-0.11 Jan 19, 2023
@kakkoyun kakkoyun deleted the fix_metadata_assoc branch January 19, 2023 16:10
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.

None yet

4 participants