expose exec-id on ctr task ps

Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
This commit is contained in:
Jess Valarezo
2017-11-03 14:49:47 -07:00
parent b4a65de5c6
commit 807f4d2ec7
12 changed files with 319 additions and 102 deletions

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,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x22, 0xad, 0xdf, 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,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x1c, 0xf7, 0xce, 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
}