Merge pull request #1718 from jessvalarezo/ctr-task-ps

ctr: update task ps command
This commit is contained in:
Kenfe-Mickaël Laventure 2017-11-10 11:58:21 -08:00 committed by GitHub
commit 17093c2f6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 351 additions and 134 deletions

View File

@ -41,8 +41,8 @@ ignore_files = [
# Lock down runc config
[[descriptors]]
prefix = "github.com/containerd/containerd/linux/runcopts"
target = "linux/runcopts/next.pb.txt"
prefix = "github.com/containerd/containerd/linux/runctypes"
target = "linux/runctypes/next.pb.txt"
ignore_files = [
"google/protobuf/descriptor.proto",
"gogoproto/gogo.proto"

View File

@ -6,7 +6,7 @@ import (
"text/tabwriter"
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/windows/hcsshimtypes"
"github.com/containerd/typeurl"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
@ -29,7 +29,6 @@ var psCommand = cli.Command{
if err != nil {
return err
}
task, err := container.Task(ctx, nil)
if err != nil {
return err
@ -38,21 +37,19 @@ var psCommand = cli.Command{
if err != nil {
return err
}
w := tabwriter.NewWriter(os.Stdout, 10, 1, 3, ' ', 0)
w := tabwriter.NewWriter(os.Stdout, 1, 8, 4, ' ', 0)
fmt.Fprintln(w, "PID\tINFO")
for _, ps := range processes {
var info interface{} = "-"
if ps.Info != nil {
var details hcsshimtypes.ProcessDetails
if err := details.Unmarshal(ps.Info.Value); err == nil {
if _, err := fmt.Fprintf(w, "%d\t%+v\n", ps.Pid, details); err != nil {
return err
}
}
} else {
if _, err := fmt.Fprintf(w, "%d\t-\n", ps.Pid); err != nil {
info, err = typeurl.UnmarshalAny(ps.Info)
if err != nil {
return err
}
}
if _, err := fmt.Fprintf(w, "%d\t%+v\n", ps.Pid, info); err != nil {
return err
}
}
return w.Flush()
},

View File

@ -18,7 +18,7 @@ import (
"github.com/containerd/cgroups"
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/containerd/linux/runctypes"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"golang.org/x/sys/unix"
@ -146,7 +146,7 @@ func TestShimInCgroup(t *testing.T) {
defer cg.Delete()
task, err := container.NewTask(ctx, empty(), func(_ context.Context, client *Client, r *TaskInfo) error {
r.Options = &runcopts.CreateOptions{
r.Options = &runctypes.CreateOptions{
ShimCgroup: path,
}
return nil
@ -887,7 +887,7 @@ func TestContainerRuntimeOptions(t *testing.T) {
ctx, id,
WithNewSpec(withImageConfig(image), withExitStatus(7)),
withNewSnapshot(id, image),
WithRuntime("io.containerd.runtime.v1.linux", &runcopts.RuncOptions{Runtime: "no-runc"}),
WithRuntime("io.containerd.runtime.v1.linux", &runctypes.RuncOptions{Runtime: "no-runc"}),
)
if err != nil {
t.Error(err)
@ -1040,7 +1040,7 @@ func testUserNamespaces(t *testing.T, readonlyRootFS bool) {
defer container.Delete(ctx, WithSnapshotCleanup)
task, err := container.NewTask(ctx, Stdio, func(_ context.Context, client *Client, r *TaskInfo) error {
r.Options = &runcopts.CreateOptions{
r.Options = &runctypes.CreateOptions{
IoUid: 1000,
IoGid: 1000,
}

View File

@ -10,7 +10,7 @@ import (
"path/filepath"
"github.com/containerd/containerd/events/exchange"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/containerd/linux/runctypes"
"github.com/containerd/containerd/linux/shim"
"github.com/containerd/containerd/linux/shim/client"
"github.com/pkg/errors"
@ -72,11 +72,11 @@ type bundle struct {
}
// ShimOpt specifies shim options for initialization and connection
type ShimOpt func(*bundle, string, *runcopts.RuncOptions) (shim.Config, client.Opt)
type ShimOpt func(*bundle, string, *runctypes.RuncOptions) (shim.Config, client.Opt)
// ShimRemote is a ShimOpt for connecting and starting a remote shim
func ShimRemote(shimBinary, daemonAddress, cgroup string, nonewns, debug bool, exitHandler func()) ShimOpt {
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.Opt) {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
return b.shimConfig(ns, ropts),
client.WithStart(shimBinary, b.shimAddress(ns), daemonAddress, cgroup, nonewns, debug, exitHandler)
}
@ -84,20 +84,20 @@ func ShimRemote(shimBinary, daemonAddress, cgroup string, nonewns, debug bool, e
// ShimLocal is a ShimOpt for using an in process shim implementation
func ShimLocal(exchange *exchange.Exchange) ShimOpt {
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.Opt) {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
return b.shimConfig(ns, ropts), client.WithLocal(exchange)
}
}
// ShimConnect is a ShimOpt for connecting to an existing remote shim
func ShimConnect() ShimOpt {
return func(b *bundle, ns string, ropts *runcopts.RuncOptions) (shim.Config, client.Opt) {
return func(b *bundle, ns string, ropts *runctypes.RuncOptions) (shim.Config, client.Opt) {
return b.shimConfig(ns, ropts), client.WithConnect(b.shimAddress(ns))
}
}
// NewShimClient connects to the shim managing the bundle and tasks creating it if needed
func (b *bundle) NewShimClient(ctx context.Context, namespace string, getClientOpts ShimOpt, runcOpts *runcopts.RuncOptions) (*client.Client, error) {
func (b *bundle) NewShimClient(ctx context.Context, namespace string, getClientOpts ShimOpt, runcOpts *runctypes.RuncOptions) (*client.Client, error) {
cfg, opt := getClientOpts(b, namespace, runcOpts)
return client.New(ctx, cfg, opt)
}
@ -120,7 +120,7 @@ func (b *bundle) shimAddress(namespace string) string {
return filepath.Join(string(filepath.Separator), "containerd-shim", namespace, b.id, "shim.sock")
}
func (b *bundle) shimConfig(namespace string, runcOptions *runcopts.RuncOptions) shim.Config {
func (b *bundle) shimConfig(namespace string, runcOptions *runctypes.RuncOptions) shim.Config {
var (
criuPath string
runtimeRoot string

View File

@ -1,5 +1,5 @@
file {
name: "github.com/containerd/containerd/linux/runcopts/runc.proto"
name: "github.com/containerd/containerd/linux/runctypes/runc.proto"
package: "containerd.linux.runc"
dependency: "gogoproto/gogo.proto"
message_type {
@ -165,8 +165,18 @@ file {
json_name: "cgroupsMode"
}
}
message_type {
name: "ProcessDetails"
field {
name: "exec_id"
number: 1
label: LABEL_OPTIONAL
type: TYPE_STRING
json_name: "execId"
}
}
options {
go_package: "github.com/containerd/containerd/linux/runcopts;runcopts"
go_package: "github.com/containerd/containerd/linux/runctypes;runctypes"
}
syntax: "proto3"
}

View File

@ -1,18 +1,19 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: github.com/containerd/containerd/linux/runcopts/runc.proto
// source: github.com/containerd/containerd/linux/runctypes/runc.proto
/*
Package runcopts is a generated protocol buffer package.
Package runctypes is a generated protocol buffer package.
It is generated from these files:
github.com/containerd/containerd/linux/runcopts/runc.proto
github.com/containerd/containerd/linux/runctypes/runc.proto
It has these top-level messages:
RuncOptions
CreateOptions
CheckpointOptions
ProcessDetails
*/
package runcopts
package runctypes
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
@ -78,10 +79,19 @@ func (m *CheckpointOptions) Reset() { *m = CheckpointOptions{
func (*CheckpointOptions) ProtoMessage() {}
func (*CheckpointOptions) Descriptor() ([]byte, []int) { return fileDescriptorRunc, []int{2} }
type ProcessDetails struct {
ExecID string `protobuf:"bytes,1,opt,name=exec_id,json=execId,proto3" json:"exec_id,omitempty"`
}
func (m *ProcessDetails) Reset() { *m = ProcessDetails{} }
func (*ProcessDetails) ProtoMessage() {}
func (*ProcessDetails) Descriptor() ([]byte, []int) { return fileDescriptorRunc, []int{3} }
func init() {
proto.RegisterType((*RuncOptions)(nil), "containerd.linux.runc.RuncOptions")
proto.RegisterType((*CreateOptions)(nil), "containerd.linux.runc.CreateOptions")
proto.RegisterType((*CheckpointOptions)(nil), "containerd.linux.runc.CheckpointOptions")
proto.RegisterType((*ProcessDetails)(nil), "containerd.linux.runc.ProcessDetails")
}
func (m *RuncOptions) Marshal() (dAtA []byte, err error) {
size := m.Size()
@ -333,6 +343,30 @@ func (m *CheckpointOptions) MarshalTo(dAtA []byte) (int, error) {
return i, nil
}
func (m *ProcessDetails) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *ProcessDetails) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.ExecID) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintRunc(dAtA, i, uint64(len(m.ExecID)))
i += copy(dAtA[i:], m.ExecID)
}
return i, nil
}
func encodeVarintRunc(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
@ -438,6 +472,16 @@ func (m *CheckpointOptions) Size() (n int) {
return n
}
func (m *ProcessDetails) Size() (n int) {
var l int
_ = l
l = len(m.ExecID)
if l > 0 {
n += 1 + l + sovRunc(uint64(l))
}
return n
}
func sovRunc(x uint64) (n int) {
for {
n++
@ -500,6 +544,16 @@ func (this *CheckpointOptions) String() string {
}, "")
return s
}
func (this *ProcessDetails) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&ProcessDetails{`,
`ExecID:` + fmt.Sprintf("%v", this.ExecID) + `,`,
`}`,
}, "")
return s
}
func valueToStringRunc(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
@ -1168,6 +1222,85 @@ func (m *CheckpointOptions) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *ProcessDetails) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRunc
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: ProcessDetails: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: ProcessDetails: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ExecID", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRunc
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthRunc
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ExecID = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipRunc(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthRunc
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipRunc(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
@ -1274,40 +1407,43 @@ var (
)
func init() {
proto.RegisterFile("github.com/containerd/containerd/linux/runcopts/runc.proto", fileDescriptorRunc)
proto.RegisterFile("github.com/containerd/containerd/linux/runctypes/runc.proto", fileDescriptorRunc)
}
var fileDescriptorRunc = []byte{
// 495 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x93, 0x31, 0x6f, 0xd3, 0x40,
0x14, 0xc7, 0x7b, 0xb4, 0x4d, 0x9c, 0x4b, 0x53, 0xe0, 0x20, 0xd2, 0x51, 0x84, 0x09, 0x11, 0x48,
0x61, 0x49, 0x24, 0x58, 0x10, 0x6c, 0x64, 0x60, 0x00, 0x4a, 0x65, 0xe8, 0xc2, 0x72, 0x72, 0xcf,
0x87, 0xf3, 0x94, 0xf8, 0xde, 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8, 0x87, 0xe5, 0xf7, 0x9d, 0xd6, 0xab, 0x02,
0xc5, 0xd1, 0x61, 0xdc, 0x2a, 0xad, 0xa3, 0x74, 0xff, 0xf4, 0xea, 0xba, 0xbf, 0xf2, 0xed, 0xba,
0xbf, 0x72, 0xb9, 0xec, 0x07, 0x57, 0xcb, 0x7e, 0xf0, 0x75, 0xd9, 0x0f, 0x7e, 0x2c, 0xfb, 0xc1,
0xc7, 0x97, 0x7f, 0x7b, 0xd0, 0x7b, 0x37, 0xea, 0xbc, 0xe5, 0x2f, 0xf5, 0xf9, 0xaf, 0x00, 0x00,
0x00, 0xff, 0xff, 0x88, 0x16, 0x9c, 0x1e, 0x15, 0x04, 0x00, 0x00,
}

View File

@ -4,7 +4,7 @@ package containerd.linux.runc;
import "gogoproto/gogo.proto";
option go_package = "github.com/containerd/containerd/linux/runcopts;runcopts";
option go_package = "github.com/containerd/containerd/linux/runctypes;runctypes";
message RuncOptions {
string runtime = 1;
@ -36,3 +36,7 @@ message CheckpointOptions {
repeated string empty_namespaces = 6;
string cgroups_mode = 7;
}
message ProcessDetails {
string exec_id = 1;
}

View File

@ -17,7 +17,7 @@ import (
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/events/exchange"
"github.com/containerd/containerd/identifiers"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/containerd/linux/runctypes"
client "github.com/containerd/containerd/linux/shim"
shim "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/log"
@ -193,7 +193,7 @@ func (r *Runtime) Create(ctx context.Context, id string, opts runtime.CreateOpts
if err != nil {
return nil, err
}
cgroup = v.(*runcopts.CreateOptions).ShimCgroup
cgroup = v.(*runctypes.CreateOptions).ShimCgroup
}
exitHandler := func() {
log.G(ctx).WithField("id", id).Info("shim reaped")
@ -493,7 +493,7 @@ func (r *Runtime) getRuntime(ctx context.Context, ns, id string) (*runc.Runc, er
}, nil
}
func (r *Runtime) getRuncOptions(ctx context.Context, id string) (*runcopts.RuncOptions, error) {
func (r *Runtime) getRuncOptions(ctx context.Context, id string) (*runctypes.RuncOptions, error) {
var container containers.Container
if err := r.db.View(func(tx *bolt.Tx) error {
@ -510,7 +510,7 @@ func (r *Runtime) getRuncOptions(ctx context.Context, id string) (*runcopts.Runc
if err != nil {
return nil, err
}
ropts, ok := v.(*runcopts.RuncOptions)
ropts, ok := v.(*runctypes.RuncOptions)
if !ok {
return nil, errors.New("invalid runtime options format")
}

View File

@ -16,7 +16,7 @@ import (
"github.com/containerd/console"
"github.com/containerd/containerd/identifiers"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/containerd/linux/runctypes"
shimapi "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
@ -67,13 +67,13 @@ func (s *Service) newInitProcess(context context.Context, r *shimapi.CreateTaskR
if err := identifiers.Validate(r.ID); err != nil {
return nil, errors.Wrapf(err, "invalid task id")
}
var options runcopts.CreateOptions
var options runctypes.CreateOptions
if r.Options != nil {
v, err := typeurl.UnmarshalAny(r.Options)
if err != nil {
return nil, err
}
options = *v.(*runcopts.CreateOptions)
options = *v.(*runctypes.CreateOptions)
}
rootfs := filepath.Join(s.config.Path, "rootfs")
@ -332,13 +332,13 @@ func (p *initProcess) Stdin() io.Closer {
}
func (p *initProcess) checkpoint(context context.Context, r *shimapi.CheckpointTaskRequest) error {
var options runcopts.CheckpointOptions
var options runctypes.CheckpointOptions
if r.Options != nil {
v, err := typeurl.UnmarshalAny(r.Options)
if err != nil {
return err
}
options = *v.(*runcopts.CheckpointOptions)
options = *v.(*runctypes.CheckpointOptions)
}
var actions []runc.CheckpointAction
if !options.Exit {

View File

@ -15,12 +15,14 @@ import (
"github.com/containerd/containerd/api/types/task"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/events"
"github.com/containerd/containerd/linux/runctypes"
shimapi "github.com/containerd/containerd/linux/shim/v1"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/reaper"
"github.com/containerd/containerd/runtime"
runc "github.com/containerd/go-runc"
"github.com/containerd/typeurl"
google_protobuf "github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@ -357,9 +359,23 @@ func (s *Service) ListPids(ctx context.Context, r *shimapi.ListPidsRequest) (*sh
}
var processes []*task.ProcessInfo
for _, pid := range pids {
processes = append(processes, &task.ProcessInfo{
pInfo := task.ProcessInfo{
Pid: pid,
})
}
for _, p := range s.processes {
if p.Pid() == int(pid) {
d := &runctypes.ProcessDetails{
ExecID: p.ID(),
}
a, err := typeurl.MarshalAny(d)
if err != nil {
return nil, errors.Wrapf(err, "failed to marshal process %d info", pid)
}
pInfo.Info = a
break
}
}
processes = append(processes, &pInfo)
}
return &shimapi.ListPidsResponse{
Processes: processes,

View File

@ -182,7 +182,8 @@ func (t *Task) Pids(ctx context.Context) ([]runtime.ProcessInfo, error) {
var processList []runtime.ProcessInfo
for _, p := range resp.Processes {
processList = append(processList, runtime.ProcessInfo{
Pid: p.Pid,
Pid: p.Pid,
Info: p.Info,
})
}
return processList, nil

View File

@ -348,7 +348,7 @@ func (s *service) ListPids(ctx context.Context, r *api.ListPidsRequest) (*api.Li
}
var processes []*task.ProcessInfo
for _, p := range processList {
processInfo := task.ProcessInfo{
pInfo := task.ProcessInfo{
Pid: p.Pid,
}
if p.Info != nil {
@ -356,9 +356,9 @@ func (s *service) ListPids(ctx context.Context, r *api.ListPidsRequest) (*api.Li
if err != nil {
return nil, errors.Wrapf(err, "failed to marshal process %d info", p.Pid)
}
processInfo.Info = a
pInfo.Info = a
}
processes = append(processes, &processInfo)
processes = append(processes, &pInfo)
}
return &api.ListPidsResponse{
Processes: processes,

View File

@ -5,7 +5,7 @@ import (
"syscall"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/linux/runcopts"
"github.com/containerd/containerd/linux/runctypes"
"github.com/containerd/containerd/mount"
)
@ -22,7 +22,7 @@ func WithRootFS(mounts []mount.Mount) NewTaskOpts {
// WithExit causes the task to exit after a successful checkpoint
func WithExit(r *CheckpointTaskInfo) error {
r.Options = &runcopts.CheckpointOptions{
r.Options = &runctypes.CheckpointOptions{
Exit: true,
}
return nil

View File

@ -60,6 +60,7 @@ type ProcessDetails struct {
MemoryWorkingSetSharedBytes uint64 `protobuf:"varint,6,opt,name=memory_working_set_shared_bytes,json=memoryWorkingSetSharedBytes,proto3" json:"memory_working_set_shared_bytes,omitempty"`
ProcessID uint32 `protobuf:"varint,7,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"`
UserTime_100Ns uint64 `protobuf:"varint,8,opt,name=user_time_100_ns,json=userTime100Ns,proto3" json:"user_time_100_ns,omitempty"`
ExecID string `protobuf:"bytes,9,opt,name=exec_id,json=execId,proto3" json:"exec_id,omitempty"`
}
func (m *ProcessDetails) Reset() { *m = ProcessDetails{} }
@ -155,6 +156,12 @@ func (m *ProcessDetails) MarshalTo(dAtA []byte) (int, error) {
i++
i = encodeVarintHcsshim(dAtA, i, uint64(m.UserTime_100Ns))
}
if len(m.ExecID) > 0 {
dAtA[i] = 0x4a
i++
i = encodeVarintHcsshim(dAtA, i, uint64(len(m.ExecID)))
i += copy(dAtA[i:], m.ExecID)
}
return i, nil
}
@ -202,6 +209,10 @@ func (m *ProcessDetails) Size() (n int) {
if m.UserTime_100Ns != 0 {
n += 1 + sovHcsshim(uint64(m.UserTime_100Ns))
}
l = len(m.ExecID)
if l > 0 {
n += 1 + l + sovHcsshim(uint64(l))
}
return n
}
@ -241,6 +252,7 @@ func (this *ProcessDetails) String() string {
`MemoryWorkingSetSharedBytes:` + fmt.Sprintf("%v", this.MemoryWorkingSetSharedBytes) + `,`,
`ProcessID:` + fmt.Sprintf("%v", this.ProcessID) + `,`,
`UserTime_100Ns:` + fmt.Sprintf("%v", this.UserTime_100Ns) + `,`,
`ExecID:` + fmt.Sprintf("%v", this.ExecID) + `,`,
`}`,
}, "")
return s
@ -535,6 +547,35 @@ func (m *ProcessDetails) Unmarshal(dAtA []byte) error {
break
}
}
case 9:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ExecID", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowHcsshim
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthHcsshim
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ExecID = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipHcsshim(dAtA[iNdEx:])
@ -666,35 +707,37 @@ func init() {
}
var fileDescriptorHcsshim = []byte{
// 479 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x92, 0x41, 0x6f, 0xd3, 0x30,
0x14, 0xc7, 0x1b, 0x36, 0xc6, 0x62, 0x54, 0x60, 0x86, 0x43, 0x28, 0x90, 0x54, 0xbb, 0x50, 0x09,
0x94, 0x74, 0x70, 0xe4, 0x44, 0x5a, 0x21, 0xed, 0x32, 0xa6, 0x0c, 0x09, 0x09, 0x21, 0x59, 0x6e,
0xf2, 0x48, 0xad, 0xd5, 0x71, 0x64, 0xbb, 0x54, 0xbd, 0xf1, 0x11, 0x38, 0xf2, 0x49, 0xf8, 0x0c,
0x3d, 0x72, 0xe4, 0x34, 0x58, 0x3e, 0x09, 0x8a, 0xed, 0x96, 0x51, 0x38, 0x71, 0xf3, 0xf3, 0xff,
0xf7, 0x7e, 0xaf, 0x7e, 0x0d, 0x1a, 0x95, 0x4c, 0x4f, 0xe7, 0x93, 0x38, 0x17, 0x3c, 0xc9, 0x45,
0xa5, 0x29, 0xab, 0x40, 0x16, 0x57, 0x8f, 0x0b, 0x56, 0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, 0xf8, 0x3c, 0x03, 0x00, 0x00,
// 503 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x41, 0x6f, 0xd3, 0x30,
0x14, 0xc7, 0x1b, 0x36, 0xba, 0xc5, 0xa8, 0xc0, 0x0c, 0x87, 0x52, 0x20, 0xa9, 0xc6, 0x81, 0x4a,
0xa0, 0xb4, 0x83, 0x23, 0x27, 0xd2, 0x82, 0xd4, 0xcb, 0x98, 0x32, 0x24, 0x24, 0x84, 0x64, 0xb9,
0xc9, 0x23, 0xb5, 0x56, 0xc7, 0x91, 0xed, 0xd2, 0xf5, 0xc6, 0x47, 0xe0, 0xc8, 0x47, 0xea, 0x91,
0x23, 0x12, 0x52, 0x61, 0xf9, 0x24, 0xc8, 0x76, 0xba, 0x8d, 0xc1, 0x89, 0x9b, 0xed, 0xff, 0xef,
0xfd, 0x5e, 0xfc, 0xac, 0xa0, 0x61, 0xce, 0xf4, 0x74, 0x3e, 0x89, 0x52, 0xc1, 0xfb, 0xa9, 0x28,
0x34, 0x65, 0x05, 0xc8, 0xec, 0xf2, 0x72, 0xc1, 0x8a, 0x4c, 0x2c, 0x54, 0x7f, 0x9a, 0x2a, 0x35,
0x65, 0x5c, 0x2f, 0x4b, 0x38, 0xdf, 0x44, 0xa5, 0x14, 0x5a, 0xe0, 0xce, 0x05, 0x1e, 0xd5, 0x78,
0x54, 0x13, 0x9d, 0xbb, 0xb9, 0xc8, 0x85, 0xc5, 0xfa, 0x66, 0xe5, 0x2a, 0x3a, 0x41, 0x2e, 0x44,
0x3e, 0x83, 0xbe, 0xdd, 0x4d, 0xe6, 0x1f, 0xfb, 0xd9, 0x5c, 0x52, 0xcd, 0x44, 0x51, 0xe7, 0xe1,
0xd5, 0x5c, 0x33, 0x0e, 0x4a, 0x53, 0x5e, 0x3a, 0x60, 0x3f, 0x45, 0xad, 0xa1, 0x04, 0xaa, 0xe1,
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ce, 0x61, 0xc7, 0xa0, 0x8f, 0x1c, 0xe4, 0x3c,
0x23, 0x14, 0xfe, 0xc3, 0xa3, 0xa6, 0x54, 0x42, 0x56, 0x6b, 0x9a, 0x56, 0x73, 0xff, 0xaa, 0xe6,
0xd8, 0x32, 0xce, 0xf2, 0x14, 0xa1, 0xd2, 0x0d, 0x98, 0xb0, 0xac, 0xbd, 0xd3, 0xf5, 0x7a, 0xad,
0xb8, 0x55, 0xad, 0x43, 0xbf, 0x1e, 0xfb, 0x78, 0x94, 0xf8, 0x35, 0x30, 0xce, 0xf0, 0x63, 0x74,
0x7b, 0xae, 0x40, 0xfe, 0x31, 0x96, 0x5d, 0xdb, 0xa4, 0x65, 0xce, 0x2f, 0x86, 0xf2, 0x08, 0xed,
0xc0, 0x29, 0xa4, 0xc6, 0xe9, 0x9b, 0x27, 0x8a, 0x51, 0xb5, 0x0e, 0x9b, 0xaf, 0x4e, 0x21, 0x1d,
0x8f, 0x92, 0xa6, 0x89, 0xc6, 0x59, 0xfc, 0x61, 0x75, 0x16, 0x34, 0xbe, 0x9f, 0x05, 0x8d, 0xcf,
0x55, 0xe0, 0xad, 0xaa, 0xc0, 0xfb, 0x56, 0x05, 0xde, 0xaf, 0x2a, 0xf0, 0xde, 0xc7, 0xff, 0xf5,
0x53, 0xbc, 0xb8, 0xbc, 0x99, 0x34, 0xed, 0x6b, 0x3f, 0xff, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xff,
0xc7, 0x40, 0x0e, 0x61, 0x03, 0x00, 0x00,
}

View File

@ -23,4 +23,5 @@ message ProcessDetails {
uint64 memory_working_set_shared_bytes = 6;
uint32 process_id = 7;
uint64 user_time_100_ns = 8;
string exec_id = 9;
}

View File

@ -144,6 +144,13 @@ file {
type: TYPE_UINT64
json_name: "userTime100Ns"
}
field {
name: "exec_id"
number: 9
label: LABEL_OPTIONAL
type: TYPE_STRING
json_name: "execId"
}
}
options {
go_package: "github.com/containerd/containerd/windows/hcsshimtypes;hcsshimtypes"

View File

@ -99,6 +99,10 @@ func (p *process) Pid() uint32 {
return p.pid
}
func (p *process) HcsPid() uint32 {
return uint32(p.hcs.Pid())
}
func (p *process) ExitCode() (uint32, time.Time, error) {
if s := p.Status(); s != runtime.StoppedStatus && s != runtime.CreatedStatus {
return 255, time.Time{}, errors.Wrapf(errdefs.ErrFailedPrecondition, "process is not stopped: %s", s)

View File

@ -218,24 +218,36 @@ func (t *task) Pids(ctx context.Context) ([]runtime.ProcessInfo, error) {
t.Lock()
defer t.Unlock()
var infoList []runtime.ProcessInfo
var processList []runtime.ProcessInfo
hcsProcessList, err := t.hcsContainer.ProcessList()
if err != nil {
return nil, err
}
for _, process := range hcsProcessList {
info, err := t.convertToProcessDetails(process)
if err != nil {
return nil, err
for _, hcsProcess := range hcsProcessList {
info := &hcsshimtypes.ProcessDetails{
ImageName: hcsProcess.ImageName,
CreatedAt: hcsProcess.CreateTimestamp,
KernelTime_100Ns: hcsProcess.KernelTime100ns,
MemoryCommitBytes: hcsProcess.MemoryCommitBytes,
MemoryWorkingSetPrivateBytes: hcsProcess.MemoryWorkingSetPrivateBytes,
MemoryWorkingSetSharedBytes: hcsProcess.MemoryWorkingSetSharedBytes,
ProcessID: hcsProcess.ProcessId,
UserTime_100Ns: hcsProcess.UserTime100ns,
}
infoList = append(infoList, runtime.ProcessInfo{
Pid: process.ProcessId,
for _, p := range t.processes {
if p.HcsPid() == hcsProcess.ProcessId {
info.ExecID = p.ID()
break
}
}
processList = append(processList, runtime.ProcessInfo{
Pid: hcsProcess.ProcessId,
Info: info,
})
}
return infoList, nil
return processList, nil
}
func (t *task) Checkpoint(_ context.Context, _ string, _ *types.Any) error {
@ -397,17 +409,3 @@ func (t *task) cleanup() {
removeLayer(context.Background(), t.rwLayer)
t.Unlock()
}
// convertToProcessDetails converts a given hcsshim ProcessListItem to proto ProcessDetails
func (t *task) convertToProcessDetails(p hcsshim.ProcessListItem) (*hcsshimtypes.ProcessDetails, error) {
return &hcsshimtypes.ProcessDetails{
ImageName: p.ImageName,
CreatedAt: p.CreateTimestamp,
KernelTime_100Ns: p.KernelTime100ns,
MemoryCommitBytes: p.MemoryCommitBytes,
MemoryWorkingSetPrivateBytes: p.MemoryWorkingSetPrivateBytes,
MemoryWorkingSetSharedBytes: p.MemoryWorkingSetSharedBytes,
ProcessID: p.ProcessId,
UserTime_100Ns: p.UserTime100ns,
}, nil
}