ListPids returns process ID and other info

Signed-off-by: Jess <jessica.valarezo@docker.com>
This commit is contained in:
Jess
2017-10-10 22:57:15 +00:00
parent 72bb45ac46
commit 061c719209
18 changed files with 1118 additions and 405 deletions

19
task.go
View File

@@ -20,6 +20,7 @@ import (
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/rootfs"
"github.com/containerd/typeurl"
google_protobuf "github.com/gogo/protobuf/types"
digest "github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/specs-go/v1"
specs "github.com/opencontainers/runtime-spec/specs-go"
@@ -41,6 +42,14 @@ type Status struct {
ExitTime time.Time
}
type ProcessInfo struct {
// Pid is the process ID
Pid uint32
// Info includes additional process information
// Info varies by platform
Info *google_protobuf.Any
}
// ProcessStatus returns a human readable status for the Process representing its current status
type ProcessStatus string
@@ -107,7 +116,7 @@ type Task interface {
// Exec creates a new process inside the task
Exec(context.Context, string, *specs.Process, IOCreation) (Process, error)
// Pids returns a list of system specific process ids inside the task
Pids(context.Context) ([]uint32, error)
Pids(context.Context) ([]ProcessInfo, error)
// Checkpoint serializes the runtime and memory information of a task into an
// OCI Index that can be push and pulled from a remote resource.
//
@@ -294,14 +303,18 @@ func (t *task) Exec(ctx context.Context, id string, spec *specs.Process, ioCreat
}, nil
}
func (t *task) Pids(ctx context.Context) ([]uint32, error) {
func (t *task) Pids(ctx context.Context) ([]ProcessInfo, error) {
response, err := t.client.TaskService().ListPids(ctx, &tasks.ListPidsRequest{
ContainerID: t.id,
})
if err != nil {
return nil, errdefs.FromGRPC(err)
}
return response.Pids, nil
var processList []ProcessInfo
for _, p := range response.Processes {
processList = append(processList, ProcessInfo(*p))
}
return processList, nil
}
func (t *task) CloseIO(ctx context.Context, opts ...IOCloserOpts) error {