runc icon indicating copy to clipboard operation
runc copied to clipboard

Refactor ps.go to use psgo library

Open marcov opened this issue 5 years ago • 7 comments

  • Refactor ps.go to use the psgo APIs instead of exec.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]

marcov avatar Jul 26 '18 16:07 marcov

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 avatar Jul 26 '18 16:07 rhatdan

@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.

vrothberg avatar Jul 26 '18 16:07 vrothberg

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.

cyphar avatar Sep 15 '18 11:09 cyphar

What's current status?

AkihiroSuda avatar Oct 31 '18 03:10 AkihiroSuda

@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...

cyphar avatar Nov 14 '18 04:11 cyphar

Is this PR needed for v1.0?

AkihiroSuda avatar Nov 14 '18 07:11 AkihiroSuda

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

cyphar avatar Nov 14 '18 09:11 cyphar