containerd / go-runc

runc bindings for Go
Apache License 2.0
161 stars 71 forks source link

runc: be able to get the full ps data (ps -f table) #37

Closed erick0z closed 6 years ago

erick0z commented 6 years ago

This is the first commit of an attempt to change the current state of the docker top behaviour. Since docker top uses ps -ef to parse the host processes with the PIDs array provided by runc.Ps() (ps -f json), this approach won't work for VM-based container runtimes like Clear Containers, runv, Kata containers. What I have in mind is to construct the ContainerTopOKBody (from github.com/moby/moby/api/types/container/container_top.go) with the data already provided by most of the OCI runtimes out there, and by removing the exec(ps -ef). This commit adds the ability to get the full ps data.

crosbymichael commented 6 years ago

How are consumers supposed to consume this programmatically?

erick0z commented 6 years ago

@crosbymichael the ps raw output is supposed to be consumed by the docker daemon (since it implements a parsePSOutput function). Programmatically, with this patch, the user can do almost nothing. What I can do is to implement a tweaked version of the parsePSOutput() function in order to return a structure (similar to ContainerTopOKBody) with all the values.

crosbymichael commented 6 years ago

Wouldn't it be better to have these runtimes output structured data? This is a hard one since the spec does not define a ps action and result but almost all the specified actions return json as the result.

https://github.com/opencontainers/runtime-spec/blob/master/runtime.md#query-state

crosbymichael commented 6 years ago

Ok, I see your latest revision. I think this is more inline and consistent with the rest of the package. lets review from there.

erick0z commented 6 years ago

@crosbymichael I honestly would prefer to have the runtime ps output defined in the OCI spec. I don't know if that's hard to introduce. Anyway, I made the changes you requested and thanks for the feedback.