-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Improve logging when cgroupfs mount fails #15999
Conversation
Looks good to me, but would appreciate someone more familiar with this to take a look. |
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.
Thanks. Could you add to your commit msg Fixes: e8ca92b45469 ("cgroups: Add stubs for non-Linux platforms")
. It will also help to check to which Cilium versions the fix has to be backported.
Also, cc @joestringer, who added the code, to double check whether we are not missing anything with the fix.
Sure! It's Done ;) |
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.
Hi Joao, can you add some additional context to the commit message about how you hit a problem here? It's not obvious to me at a glance why this is a problem. What environment did you use, what Cilium configuration, what was the behaviour that was wrong?
FYI this goes back further than e8ca92b ("cgroups: Add stubs for non-Linux platforms") , that commit only moved code around. This bug likely goes way back to its initial introduction.
Sure! I will place more infos in the commit but I would like to share something here to discuss. I was trying to solve two issues about cilium running on kind but at the first time I realized that, for some reason, cilium was not able to derive a cgroup v2 sub-hierarchy as proposed by 866969. I was following the "Getting Started Using Kind" (using the vagrant dev VMs with NETNEXT=1). After few (unsuccessful) attempts, I changed the following:
Even so, the cgroup v2 sub-hierarchy was not created. So I decided to place some prints in the code and try to understand what was going wrong looking the logs - I followed the Building Container Images guide (building the master branch). For this specific commit, If the cgroupv2 root is not mounted, the function cilium/pkg/mountinfo/mountinfo_linux.go Lines 55 to 58 in 4f27865
But after a successful mount (which does not return), the code will check if cilium/pkg/cgroups/cgroups_linux.go Lines 60 to 68 in efc15cd
I'm not sure if I miss something but IMHO this is the first thing we need to fix in order to set the sub-hierarchy. The other point seems to be related with the path format, defined in: Lines 64 to 68 in 55c46de
In my tests, cilium-agent always receives something like Lines 95 to 103 in 55c46de
Do you have any points or suggestions? |
Hi Joao, Thanks for your contribution.
Yes, this does look like a bug to me. Having said that, I'm not super familiar with the code path to explain why we haven't hit this issue before. For your 2nd question about cgroup path, I don't have a setup available to confirm your findings. I'll try to replicate your workflow. |
Hi @aditighag,
Yes, indeed! I will place more details without get into the code.
Thanks ;) |
@johngv2 Is it on cilium-agent running on Kind? If yes, which Kind version and configuration? |
@brb, exactly! I'm using kind v0.10.0 (kindest/node:v1.20.2) installed using I started the cluster with
I thought it could be something related with kindest version, so I tried the versions v1.19 and v1.18 without success. |
@joe2far Interesting. I'm running Kind v0.10.0 on Archlinux without any problems. Could you exec into all nodes and paste |
@brb , I think I get the point. The pattern used in the cgroup path seems to be related with the used cgroup driver: it can be cgroupfs, systemd (some info about this). There are some underlying details I didn't understand yet, but the relevant point for now is that we have, at least, two patterns. I made a simple test between the vagrant dev machine, and an arch linux I've installed, and I realized the differences between our environments seems to be as follows:
Btw, in the arch linux machine I have the following (after
What about to address this point in another issue? |
I think we're getting somewhere, if I understand correctly it's something like: If you deploy Cilium in a kind environment on ____ distro, by default the systemd cgroups driver is used which does not mount the cgroupsv2 filesystem in the location that Cilium expects. When Cilium attempts to check or mount the cgroupv2 filesystem, this fails with errors in the log like _______________. This commit fixes the issue by ensuring that when Cilium cannot find an existing cgroupsv2 filesystem, it can successfully mount one. The change itself LGTM, I think with some text similar to the above in the commit message, the motivation should be clear. |
If there's something off about the assumptions that Cilium is making about cgroup path patterns, I would suggest yes that can be investigated/solved separately; ideally we can also improve the unit tests to ensure that the core logic can handle different patterns. |
@johngv2 Thanks for the info. The problem is that on the vagrant you have Docker running with cgroup v1 which is not expected to work. Could you create a separate issue for that? |
@joestringer I have changed the issue message. I appreciate any suggestion ;) @brb , the new issue will be related to "create cgroupv2 sub-hierarchy for cgroupv1 driver"? |
test-me-please |
k8s-1.21-kernel-4.9 failures are hitting the issue fixed in #16767. A rebase would fix those, but I think they're safe to ignore given that everything else is passing and the functional change here is pretty minimal. CI 3.0 timing worked out a bit poorly with the merge of #16631 . Basically when this code was run, it did not include the cilium-agent code changes from that PR, however it runs against the latest version of the github actions from that PR. What this means is that the CI sets up taints saying that cilium is not ready (so pods cannot be deployed), and cilium-agent should remove those taints to allow pod deployment to proceed. However the code to do that is not present in this PR. I think this is good to just merge. If it broke cgroup mounting then we would see one of the socket LB tests in ginkgo fail out. |
When the variable
mounted
is false, we avoid to check the value ofcgroupInstance
because, after mount, it is related to an earlier state.Fixes: #15997