-
Notifications
You must be signed in to change notification settings - Fork 18
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
Pod level metrics are not being surfaced by the shim #180
Comments
I wonder if this may be the issue: containerd/cri#922. Specifically, we may need to add the |
@jprendes and I spent some time setting up GDB debugging with the shim for this. While we did not come to any new conclusions, I wanted to share our repro steps: Debugging with GDB
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "attach",
"name": "Attach to PID",
"target": "{PID}",
"cwd": "${workspaceRoot}",
"valuesFormatting": "parseText",
"gdbpath": "/home/kagold/projects/containerd-shim-spin/_scratch/resources-debug/sudo-gdb.sh"
}
]
}
|
@Mossaka and I spent today debugging this issue. We ended up making the most progress by building kubelet with debug symbols and attaching a debugger to that. I'll attach a hackmd for our steps tomorrow. For now, the main discovery was that kublet is failing to find pod stats for the wasm pods because it is using the wrong cgroup. cat /sys/fs/cgroup/kubepods.slice/kubepods-pod99afd520_5b3e_4c8d_8471_4b6c8ee26b4c.slice/cpu.stat
usage_usec 0
user_usec 0
system_usec 0
core_sched.force_idle_usec 0
nr_periods 2
nr_throttled 0
throttled_usec 0
nr_bursts 0
burst_usec 0
kagold@kagold-ThinkPad-X1-Carbon-6th:~$ cat /sys/fs/cgroup/kubepods-pod99afd520_5b3e_4c8d_8471_4b6c8ee26b4c.slice\:cri-containerd\:c339025b3f0d9bec908636b49764fbca659636f54ad45c2eddd281049eb4df00/cpu.stat
usage_usec 25442435
user_usec 13538017
system_usec 11904418
core_sched.force_idle_usec 0
nr_periods 43128
nr_throttled 130
throttled_usec 11639387
nr_bursts 0
burst_usec 0 This is the line in the kubelet that is setting pod cpu and memory stats to 0 because it grabbed the stats from the wrong cgroup. The work of gathering stats starts in `listPodStatsPartiallyFromCRI. Kubelet gathers a table of container info that is indexed. The following is an example of that table, where the first two entries are from a linux container that gets appropriate pod stats and the latter two are the wasm container. Kubelet indexes this table with key
Note that in general, the wasm container's cgroup path looked different from the other containers and doesn't conform to either of the examples commented in line in this function:
|
Great find! |
Here is a HackMD with debugging configuration for the Shim, containerd, and kubelet: https://hackmd.io/@kgoldenring/Sy2ktGfSJe Would any of this be useful to add to the repository as official documentation? |
@jsturtevant @Mossaka I am not sure where the best place to look it. We know this is likely related to cgroups, either in how we are leveraging |
I wonder if it has something to do with the handling of not using systemd to manage cgroups: https://github.com/containerd/runwasi/blob/95853b4e3339d0509bc8ea195e742442268ff6a7/crates/containerd-shim-wasm/src/sys/unix/container/instance.rs#L62 We are hitting this block of using cgroup v2 manager: https://github.com/youki-dev/youki/blob/7c67acc33e45f21f1038109c36adec44b0b505b1/crates/libcgroups/src/common.rs#L361 |
This issues seems related @Mossaka containerd/runwasi#276 |
This is a summary of a thread from the #spinkube CNCF slack. Thank you @asteurer for discovering this issue!
The issue
Initial discovery: When running a CPU intensive spin app with the shim, if load/ requests increases, CPU usage reporting on the pod stays static (output of
kubectl top pods
does not change). This makes it impossible to use the Horizontal Pod Autoscaler with SpinKube. This is consistent for all of the following tested K8s distributions -- note that the only distribution that does not exhibit this behavior is K3d:Repro steps
Output may look similar to the following:
Notice how the Pod CPU and memory usage values are 0 while the container has properly propagated values.
If Pod metrics were properly reported, the app replicas would increase.
# After port forwarding to port 3000 bombardier localhost:3000 -n 10 -t 30s
Calling the stats API during the load test shows that while the container
usageNanoCores
jumped from 4728 to 497486, the pod metrics did not change nor did the app replica count or the output ofkubectl top pods
for that Pod.Other investigation
Pod metrics are surfaced for normal containers not executed with the shim (without runtime class
wasmtime-spin-v2
specified):However, if that same container is executed with the shim, Pod metrics are no longer surfaced.
Possible solutions and areas to investigate
Some areas to investigate that @jsturtevant and @radu-matei mentioned are the following:
The text was updated successfully, but these errors were encountered: