runc
runc copied to clipboard
Refactor ps.go to use psgo library
- Refactor
ps.go
to use the psgo APIs instead ofexec.Command("ps", psArgs...)
- Add to runc ps the --print-descriptors boolean flag to retrieve all available format descriptors supported by psgo
- Update tests and documentation
- Add psgo to the vendored libraries (required by tests)
Fixes: #1851 Signed-off-by: Marco Vedovati [email protected]
There is a bit of a rewrite of the API going on in psgo, should we wait for this rewrite to be done first?
@rhatdan, @marcov and I coordinated. The API in psgo should be stable enough now and the latest changes are merged.
@marcov, in case you want to add bash-completion, feel free to have a look at the trick for podman.
This actually presents us with the possibility to fix a long-standing bug in runc ps
. Currently runc ps
assumes that the first field of ps
is the PID -- but this is obviously not always the case. So currently:
% runc ps ctr -efZ
LABEL UID PID PPID C STIME TTY TIME CMD
unexpected pid 'avahi': strconv.ParseInt: parsing "avahi": invalid syntax
Which is a problem (and I would use as a justification that nobody actually uses ps flags with runc ps
but let's just ignore that for now). I think that if we just implement ps-flag parsing and have some functions in psgo
that do this, this will be easily mergeable. I will work on this.
What's current status?
@AkihiroSuda There isn't an implementation of the psflags yet. I spoke to @marcov about it yesterday and gave an outline of how it should be done. Hopefully one of us will have a few spare cycles to implement all of the parsing.
For context, the ps
flag parsing code is very complicated and so hopefully we can implement this in a less awful manner...
Is this PR needed for v1.0?
No. Very few PRs are needed for 1.0 (and general view is that if there is a like this one which will take significant effort to get ready for 1.0, we can always get it done later). We've spent far too long merging PRs in preparation for 1.0, it's time to get it done. :P