Conversation
api.go
Outdated
|
|
||
| // PsContainer is the virtcontainers entry point to list | ||
| // processes running inside a container | ||
| func PsContainer(podID, containerID string, psArgs []string) error { |
There was a problem hiding this comment.
Maybe I am missing something here but you never return anything, right ? How do you plan to get the data back ?
Also I think it could be part of StatusContainer() instead of adding a new function to the exported API. @sameo any thoughts on this one ?
There was a problem hiding this comment.
probably I have to return a string
There was a problem hiding this comment.
I would say that you want to return a new dedicated structure. Something like:
type ProcessInfo struct {
Name string
PID string
PPID string
...
}
type PsInfo struct {
ID string
ProcessesList []ProcessInfo
}|
Related to clearcontainers/runtime#95. |
| SetupInterface: SetupInterfaceCode, | ||
| SetupRoute: SetupRouteCode, | ||
| RemoveContainer: RemoveContainerCode, | ||
| PsContainer: PsContainerCode, |
There was a problem hiding this comment.
Where in hyperstart is this defined ?
There was a problem hiding this comment.
It is not defined, not yet I'm working on that clearcontainers/hyperstart#30
There was a problem hiding this comment.
|
Depends on an hyperstart PR |
|
Related: clearcontainers/proxy#83 |
60c3834 to
01c1fee
Compare
|
@sameo @sboeuf @jodh-intel or somebody with superpowers , please remove |
01c1fee to
82477b6
Compare
82477b6 to
911e469
Compare
agent.go
Outdated
| killContainer(pod Pod, c Container, signal syscall.Signal, all bool) error | ||
|
|
||
| // psContainer will list the processes running inside the container | ||
| psContainer(pod Pod, c Container, format string, psArgs []string) ([]byte, error) |
There was a problem hiding this comment.
processListContainer seems like a more generic name IMO.
And also I would prefer a function prototype a bit different:
processListContainer(pod Pod, c Container, processListOptions []Param) (ProcessList, error)The reason here is that I would like to get the same processList structure from any agent implementation and get this structure formatted as expected from the runtime implementation.
api.go
Outdated
|
|
||
| // PsContainer is the virtcontainers entry point to list | ||
| // processes running inside a container | ||
| func PsContainer(podID, containerID string, format string, psArgs []string) ([]byte, error) { |
There was a problem hiding this comment.
s/PsContainer/ProcessListContainer/
Prototype
ProcessListContainer(podID, containerID string, processListOptions []Param) (ProcessList, error)
container.go
Outdated
| return nil | ||
| } | ||
|
|
||
| func (c *Container) ps(format string, psArgs []string) ([]byte, error) { |
There was a problem hiding this comment.
Replace
ps(format string, psArgs []string) ([]byte, error)with
processList(processListOptions []Param) (ProcessList, error)911e469 to
3f520fc
Compare
|
@sboeuf changes applied |
|
@devimc Thanks but you've addressed only half of the comments. Here is what you missed:
And
The important point here is that I think it would be better to return a generic structure that we define inside virtcontainers so that it can be reused by any runtime implementation. That means that I would expect to see the runtime doing the conversion between this structure and the expected format. |
3f520fc to
270f7e2
Compare
|
@sboeuf imo does not make sense to create a struct just for 1 element, I agree with you I'd expect the conversion of types in the runtime, for this reason I defined the type ProcessList as []byte |
jodh-intel
left a comment
There was a problem hiding this comment.
Just a minor nit.
@sboeuf - what do you think?
hyperstart.go
Outdated
|
|
||
| response, err := h.proxy.sendCmd(proxyCmd) | ||
| if msg, ok := response.([]byte); ok { | ||
| return msg, err |
There was a problem hiding this comment.
This would be clearer as follows (currently it is unclear if it's an error or not :):
return msg, nil
There was a problem hiding this comment.
yes I think this should return return msg, nil since this is the right case.
There was a problem hiding this comment.
@sboeuf - Once that's done, is this good to merge?
There was a problem hiding this comment.
@jodh-intel @devimc Yes after this is cleared up, I think we're good to merge this PR. Please could you implement like this in order to get all this clearer:
response, err := h.proxy.sendCmd(proxyCmd)
if err != nil {
return nil, err
}
if msg, ok := response.([]byte); !ok {
return nil, fmt.Errorf("failed to get response message")
}
return msg, nil270f7e2 to
b398ccc
Compare
|
@jodh-intel @sboeuf changes applied , thanks |
agent.go
Outdated
| Args []string | ||
| } | ||
|
|
||
| // ProcessList represents the list of running process inside the container |
agent.go
Outdated
| // ProcessListOptions contains the options used to list running | ||
| // processes inside the container | ||
| type ProcessListOptions struct { | ||
| // Format describes the output format to list the running processes |
There was a problem hiding this comment.
I originally thought this might be for ps(1) -o formats, so I think it would be helpful to state somehow that this is unrelated to ps(1) formats (and maybe list some). Looking at clearcontainers/agent#90, I'm wondering if it would be useful if the agent would default to table if Format="".
There was a problem hiding this comment.
sure, lemme update the comment to specify format is unrelated to ps.
default value is set in the runtime [1]
[1] - https://github.com/clearcontainers/runtime/pull/444/files#diff-b985e723bb136b291af1a569f76616d4R32
agent.go
Outdated
| // Format describes the output format to list the running processes | ||
| Format string | ||
|
|
||
| // Args contains the list of arguments to run ps command |
There was a problem hiding this comment.
Again, the agent PR shows that if this isn't set, it default to sane values so I wonder if it would be worth adding "(optional)" at the end of the comment here?
There was a problem hiding this comment.
default value is set in the runtime https://github.com/clearcontainers/runtime/pull/444/files#diff-b985e723bb136b291af1a569f76616d4R67
|
|
||
| // ProcessListContainer is the virtcontainers entry point to list | ||
| // processes running inside a container | ||
| func ProcessListContainer(podID, containerID string, options ProcessListOptions) (ProcessList, error) { |
There was a problem hiding this comment.
Since this changes the API, you'll need to also do the following:
interfaces.go: Add this function to theVCinterface).implementation.go: Add a simple wrapper like the one forSetLogger()).pkg/vcMock/types.go: Again, add a function similar toSetLoggerFunc).pkg/vcMock/mock.go: Add a simple wrapper like the one forSetLogger()).pkg/vcMock/mock_test.go: Add a simpleTestProcessListContainer().
| } | ||
|
|
||
| if state.State != StateRunning { | ||
| return nil, fmt.Errorf("Container not running, impossible to list processes") |
There was a problem hiding this comment.
Can you add c.id to the error here? Also, this is racy as the container might be running here, but by the time you call processListContainer() below it might have stopped.
hyperstart.go
Outdated
|
|
||
| msg, ok := response.([]byte) | ||
| if !ok { | ||
| return nil, fmt.Errorf("failed to get response message") |
There was a problem hiding this comment.
Would be useful to have podID and cID in the error here.
|
I should have said that above are addressed, I think this is good to land [1]. [1] - I suppose this could land before clearcontainers/agent#90 as the agent will just reject the unknown command. |
b398ccc to
9ac9ad4
Compare
9ac9ad4 to
670000b
Compare
|
@jodh-intel changes applied, thanks |
ps command is used to list the processes running inside the container, this command is called by ```docker top``` partially fixes clearcontainers/runtime#95 Signed-off-by: Julio Montes <julio.montes@intel.com>
72c9de6 to
fe38e5a
Compare
implement mock functions to test processListContainer Signed-off-by: Julio Montes <julio.montes@intel.com>
fe38e5a to
ff99e51
Compare
ps command is used to list the processes running inside
the container, this command is called by
docker toppartially fixes clearcontainers/runtime#95
Signed-off-by: Julio Montes julio.montes@intel.com