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

@@ -165,6 +165,16 @@ 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"
}

View File

@@ -11,6 +11,7 @@
RuncOptions
CreateOptions
CheckpointOptions
ProcessDetails
*/
package runcopts
@@ -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
@@ -1278,36 +1411,39 @@ func init() {
}
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, 0xe9, 0xee, 0x4c, 0x93, 0xad, 0x9f, 0x80, 0xcf, 0xd5, 0x91, 0x91,
0x91, 0xe6, 0x8b, 0x80, 0x7c, 0xb6, 0x0b, 0x2b, 0x2b, 0xdb, 0xff, 0xfd, 0xfe, 0xcf, 0x7e, 0x4f,
0xff, 0xd3, 0xa3, 0x2f, 0x73, 0xf0, 0x8b, 0xf2, 0x6c, 0x2a, 0xb1, 0x98, 0x49, 0xd4, 0x3e, 0x05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,
0x93, 0x9f, 0xdb, 0x98, 0x7c, 0x7e, 0xf1, 0x8f, 0x87, 0xf9, 0xaa, 0x15, 0x67, 0x9d, 0x70, 0x70,
0xcf, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xbe, 0xbb, 0xf0, 0x6c, 0xdb, 0x03, 0x00, 0x00,
// 536 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x93, 0xc1, 0x6e, 0xd3, 0x40,
0x10, 0x86, 0x6b, 0xda, 0x26, 0xce, 0xa4, 0x29, 0xb0, 0x50, 0xc9, 0x14, 0x91, 0x86, 0x00, 0x52,
0xb8, 0xa4, 0x12, 0x08, 0x09, 0xc1, 0xad, 0x2d, 0x42, 0x15, 0x50, 0x2a, 0x43, 0x2f, 0x5c, 0x56,
0xee, 0x7a, 0x48, 0x56, 0x89, 0x77, 0x56, 0xbb, 0x6b, 0xea, 0xdc, 0xfa, 0x04, 0x3c, 0x57, 0x8f,
0x1c, 0x39, 0x21, 0x9a, 0x17, 0x01, 0x79, 0x6d, 0x17, 0xae, 0x5c, 0xb9, 0xfd, 0xf3, 0xfd, 0x63,
0xcf, 0xe8, 0x5f, 0x0d, 0xbc, 0x98, 0x48, 0x37, 0xcd, 0x4f, 0xc7, 0x82, 0xb2, 0x5d, 0x41, 0xca,
0x25, 0x52, 0xa1, 0x49, 0xff, 0x96, 0x73, 0xa9, 0xf2, 0x62, 0xd7, 0xe4, 0x4a, 0x90, 0x76, 0xd6,
0x8b, 0xb1, 0x36, 0xe4, 0x88, 0x6d, 0xfd, 0xe9, 0x1a, 0xfb, 0xae, 0x71, 0x69, 0x6e, 0xdf, 0x9e,
0xd0, 0x84, 0x7c, 0xc7, 0x6e, 0xa9, 0xaa, 0xe6, 0xe1, 0xd7, 0x00, 0xba, 0x71, 0xae, 0xc4, 0x7b,
0xed, 0x24, 0x29, 0xcb, 0x22, 0x68, 0x9b, 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0x9c, 0xb6, 0xfc, 0x9d, 0x3e, 0xfd, 0x1d, 0x00, 0x00, 0xff, 0xff,
0x15, 0x0d, 0x16, 0x1d, 0x12, 0x04, 0x00, 0x00,
}

View File

@@ -36,3 +36,7 @@ message CheckpointOptions {
repeated string empty_namespaces = 6;
string cgroups_mode = 7;
}
message ProcessDetails {
string exec_id = 1;
}

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/runcopts"
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 := &runcopts.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