fix(ps): return all host-visible PIDs via /proc walk#731
fix(ps): return all host-visible PIDs via /proc walk#731Chennamma-Hotkar wants to merge 1 commit into
Conversation
Previously ps only returned the monitor PID. Now getAllDescendants() recursively walks /proc/<pid>/task/<pid>/children to include all VMM sub-processes and virtiofsd in the output. Closes urunc-dev#637 Signed-off-by: Chennamma-Hotkar <channuhotkar@gmail.com>
✅ Deploy Preview for urunc ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Hello @Chennamma-Hotkar , thank you for the PR, but as discussed in the issue, trying to manually find all descendants would be hard with quite some unnecessary overhead. Instead, we can use cgroups when we finally add support for them. |
|
Hi @cmainas, that makes sense - cgroups would be a much cleaner long-term solution for tracking all container processes without the /proc walk overhead. Should I:
Happy to help with cgroup support if that's the direction the project wants to go - just let me know how I can contribute there. |
|
We are currently working in cgroup support. We can close this PR for the time being. |
|
Understood, thank you! I'll close this PR. Would love to help with the cgroup support work if there's room to contribute. Is there an existing issue or PR I could look at to see where things stand? |
Description
Previously,
urunc psonly returned the sandbox monitor PID stored instate.json. This left VMM sub-processes (e.g. QEMU threads) and virtiofsd invisible to operators and container orchestrators, breaking cgroup accounting and process visibility.This PR adds
getAllDescendants()which recursively walks/proc/<pid>/task/<pid>/childrento collect all host-visible PIDsrooted at the monitor process. Since virtiofsd is spawned before
syscall.Exec(), it naturally becomes a child of the monitor PID and is included in the walk automatically.Related issues
How was this tested?
Unit tests added in
cmd/urunc/ps_test.go:TestGetAllDescendants_IncludesRoot— root PID is always presentTestGetAllDescendants_NonExistentPID— graceful handling of dead processTestGetAllDescendants_IncludesChild— spawned child process is detectedAll existing unit tests pass:
go test ./cmd/urunc/... ./pkg/unikontainers/... -short -timeout 60sTest Results
LLM usage
N/A
Checklist
make lint).make test_ctr,make test_nerdctl,make test_docker,make test_crictl).