agent: implement ps command#90
Conversation
d60d1cd to
bd7c555
Compare
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
I get that this whole function is about duplicating what runc does here https://github.com/opencontainers/runc/blob/master/ps.go#L41-L95, but I think we should add an added value, that is gather all those data inside a structure dedicated to this. This structure would be then marshalled so that it would become a JSON byte array that we can send to the runtime(virtcontainers basically).
There was a problem hiding this comment.
do you mean to put all output inside a struct?
type psOutput struct {
output byte[]
}
I wonder if this is really needed
There was a problem hiding this comment.
@devimc no, I meant having something nicer than only an array of byte already in the expected format. Basically, I was thinking that the agent could parse the output of the ps command to put it into a structure like:
type processInfo struct {
Name string
PID string
...
}
type processListInfo []processInfoAnd this would be marshalled into a json byte array through the response. Then we would have virtcontainers relying on this specific structure to unmarshal the byte array. And then, this structure would be passed back to the runtime. The runtime wrapper being the only one doing the formatting.
I am saying all of this because if we think about virtcontainers as a generic library, we want to return a process list as a standardized structure that any consumer of virtcontainers could format the way it wants.
There was a problem hiding this comment.
@sboeuf the problem with the structure that you propose is that we don't know the options user will provide
There was a problem hiding this comment.
That's why we need to have every potential output covered by this structure. The output will depend on the options, I agree, but eventually we would be sending the same structure.
There was a problem hiding this comment.
@devimc I don't think you're marshalling an actual structure that the runtime/virtcontainers could unmarshal and format filter, right ?
There was a problem hiding this comment.
runc doesn't format/filter the output because docker does that [1], I consider we should have a similar implementation and leave to docker decide the output format.
[1] - https://github.com/moby/moby/blob/402540708c9a0c35dc0b279a0f330455633537b8/daemon/top_unix.go#L63
agent.go
Outdated
| hyper.ReadyCmd: readyCb, | ||
| hyper.PingCmd: pingCb, | ||
| hyper.WinsizeCmd: winsizeCb, | ||
| hyper.PsContainerCmd: processListCb, |
There was a problem hiding this comment.
Because it has to return a reply, it should be part of a different map. Create a new one called callbackWithReplyList
| func (p *pod) runCmd(cmd hyper.HyperCmd, data []byte) error { | ||
| func (p *pod) runCmd(cmd hyper.HyperCmd, data []byte) ([]byte, error) { | ||
| cb, exist := callbackList[cmd] | ||
| if exist == false { |
There was a problem hiding this comment.
This check should not return an error anymore. Indeed, relying on what I have mentioned above, if we add this new Hyper command to a new map called callbackWithReplyList, we should not fail but instead, we should try this other list. If we cannot find for both lists, then we can really fail this time.
This would allow not to force all the other commands to return nil all the time because they have no byte to send back.
6c257e0 to
8b23a6f
Compare
ps command is used to list the processes running inside the container, this command is called by ```docker top``` fixes clearcontainers#91 partially fixes clearcontainers/runtime#95 Signed-off-by: Julio Montes <julio.montes@intel.com>
8b23a6f to
300f661
Compare
|
@sameo ping |
|
@sboeuf Please let us know if you're ready to LGTM that PR. |
ps command is used to list the processes running inside
the container, this command is called by
docker topfixes #91
partially fixes clearcontainers/runtime#95
Signed-off-by: Julio Montes julio.montes@intel.com