diff --git a/cmd/containerd-shim-runhcs-v1/service.go b/cmd/containerd-shim-runhcs-v1/service.go index 2c75da4a98..eed5ec9f4a 100644 --- a/cmd/containerd-shim-runhcs-v1/service.go +++ b/cmd/containerd-shim-runhcs-v1/service.go @@ -2,6 +2,7 @@ package main import ( "context" + "os" "runtime" "strings" "sync" @@ -474,3 +475,18 @@ func (s *service) DiagStacks(ctx context.Context, req *shimdiag.StacksRequest) ( } return resp, nil } + +func (s *service) DiagPid(ctx context.Context, req *shimdiag.PidRequest) (*shimdiag.PidResponse, error) { + if s == nil { + return nil, nil + } + defer panicRecover() + ctx, span := trace.StartSpan(ctx, "DiagPid") + defer span.End() + + span.AddAttributes(trace.StringAttribute("tid", s.tid)) + + return &shimdiag.PidResponse{ + Pid: int32(os.Getpid()), + }, nil +} diff --git a/cmd/shimdiag/list.go b/cmd/shimdiag/list.go index ce86959512..9085f72209 100644 --- a/cmd/shimdiag/list.go +++ b/cmd/shimdiag/list.go @@ -1,9 +1,13 @@ package main import ( + "context" "fmt" + "os" + "text/tabwriter" "github.com/Microsoft/hcsshim/internal/appargs" + "github.com/Microsoft/hcsshim/internal/shimdiag" "github.com/urfave/cli" ) @@ -11,15 +15,55 @@ var listCommand = cli.Command{ Name: "list", Usage: "Lists running shims", ArgsUsage: " ", - Before: appargs.Validate(), + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "pids", + Usage: "Shows the process IDs of each shim", + }, + }, + Before: appargs.Validate(), Action: func(ctx *cli.Context) error { + pids := ctx.Bool("pids") shims, err := findShims("") if err != nil { return err } + + getPid := func(shimStr string) (int32, error) { + shim, err := getShim(shimStr) + if err != nil { + return 0, err + } + defer shim.Close() + + svc := shimdiag.NewShimDiagClient(shim) + resp, err := svc.DiagPid(context.Background(), &shimdiag.PidRequest{}) + if err != nil { + return 0, err + } + return resp.Pid, nil + } + + w := new(tabwriter.Writer) + w.Init(os.Stdout, 0, 8, 0, '\t', 0) + + if pids { + fmt.Fprintln(w, "Shim \t Pid") + } + for _, shim := range shims { - fmt.Println(shim) + output := shim + if pids { + pid, err := getPid(shim) + if err != nil { + return err + } + fmt.Fprintf(w, "%s \t %d\n", output, pid) + } else { + fmt.Println(shim) + } } + w.Flush() return nil }, } diff --git a/internal/shimdiag/shimdiag.pb.go b/internal/shimdiag/shimdiag.pb.go index 2898b289ea..7a44c3064c 100644 --- a/internal/shimdiag/shimdiag.pb.go +++ b/internal/shimdiag/shimdiag.pb.go @@ -265,6 +265,83 @@ func (m *ShareResponse) XXX_DiscardUnknown() { var xxx_messageInfo_ShareResponse proto.InternalMessageInfo +type PidRequest struct { + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PidRequest) Reset() { *m = PidRequest{} } +func (*PidRequest) ProtoMessage() {} +func (*PidRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c7933dc6ffbb8784, []int{6} +} +func (m *PidRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PidRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PidRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PidRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_PidRequest.Merge(m, src) +} +func (m *PidRequest) XXX_Size() int { + return m.Size() +} +func (m *PidRequest) XXX_DiscardUnknown() { + xxx_messageInfo_PidRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_PidRequest proto.InternalMessageInfo + +type PidResponse struct { + Pid int32 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PidResponse) Reset() { *m = PidResponse{} } +func (*PidResponse) ProtoMessage() {} +func (*PidResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c7933dc6ffbb8784, []int{7} +} +func (m *PidResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PidResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PidResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalTo(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PidResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PidResponse.Merge(m, src) +} +func (m *PidResponse) XXX_Size() int { + return m.Size() +} +func (m *PidResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PidResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_PidResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*ExecProcessRequest)(nil), "containerd.runhcs.v1.diag.ExecProcessRequest") proto.RegisterType((*ExecProcessResponse)(nil), "containerd.runhcs.v1.diag.ExecProcessResponse") @@ -272,6 +349,8 @@ func init() { proto.RegisterType((*StacksResponse)(nil), "containerd.runhcs.v1.diag.StacksResponse") proto.RegisterType((*ShareRequest)(nil), "containerd.runhcs.v1.diag.ShareRequest") proto.RegisterType((*ShareResponse)(nil), "containerd.runhcs.v1.diag.ShareResponse") + proto.RegisterType((*PidRequest)(nil), "containerd.runhcs.v1.diag.PidRequest") + proto.RegisterType((*PidResponse)(nil), "containerd.runhcs.v1.diag.PidResponse") } func init() { @@ -279,38 +358,41 @@ func init() { } var fileDescriptor_c7933dc6ffbb8784 = []byte{ - // 490 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x6f, 0xd4, 0x30, - 0x10, 0x5d, 0xb7, 0xdd, 0x25, 0x19, 0x4a, 0x91, 0x4c, 0x85, 0xd2, 0xac, 0x14, 0x2d, 0xb9, 0x10, - 0x0e, 0x24, 0xa2, 0x1c, 0x38, 0x20, 0x2e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, 0x5c, 0x04, 0xc0, 0x1a, 0xb6, 0x09, 0xe0, 0xe4, 0x02, 0xf5, 0xb9, 0xe0, 0xc3, 0x7b, - 0x97, 0xe8, 0xec, 0x2c, 0x3e, 0x82, 0xef, 0x2c, 0xec, 0xd6, 0xf8, 0xee, 0x45, 0xba, 0x3f, 0xc2, - 0x0f, 0x93, 0xff, 0x37, 0xb6, 0xf3, 0x9f, 0xbe, 0x3b, 0x3d, 0x8b, 0x06, 0x3f, 0xcf, 0xa2, 0xc1, - 0xd7, 0x55, 0x84, 0x4e, 0x57, 0x11, 0xfa, 0xb1, 0x8a, 0xd0, 0xaf, 0x55, 0x84, 0x3e, 0x3c, 0xba, - 0xda, 0xcb, 0x7b, 0xdc, 0x17, 0xef, 0x07, 0x87, 0x23, 0xf7, 0x96, 0x1e, 0xfe, 0x0e, 0x00, 0x00, - 0xff, 0xff, 0x2a, 0xac, 0x9a, 0x75, 0xbd, 0x03, 0x00, 0x00, + // 534 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0x8e, 0x49, 0x93, 0xda, 0xd3, 0x50, 0xd0, 0x52, 0x21, 0xd7, 0x91, 0x4c, 0xb0, 0x04, 0x98, + 0x03, 0x8e, 0x28, 0x07, 0x0e, 0x88, 0x0b, 0x3f, 0x12, 0x08, 0x21, 0x42, 0x72, 0xa9, 0x38, 0x10, + 0x6d, 0xed, 0xc5, 0x5e, 0x35, 0xde, 0x0d, 0xbb, 0xeb, 0xd0, 0xde, 0x78, 0x0c, 0x1e, 0x80, 0x87, + 0xe9, 0x91, 0x23, 0x47, 0x9a, 0x27, 0x41, 0xbb, 0x5e, 0x07, 0x2a, 0x44, 0xda, 0x9e, 0x32, 0xdf, + 0xb7, 0xf3, 0xcd, 0xec, 0x7c, 0xb3, 0x31, 0x3c, 0xcd, 0xa9, 0x2a, 0xaa, 0x83, 0x24, 0xe5, 0xe5, + 0xf0, 0x2d, 0x4d, 0x05, 0x97, 0xfc, 0x93, 0x1a, 0x16, 0xa9, 0x94, 0x05, 0x2d, 0x87, 0x94, 0x29, + 0x22, 0x18, 0x9e, 0x0d, 0x35, 0xca, 0x28, 0xce, 0x57, 0x41, 0x32, 0x17, 0x5c, 0x71, 0xb4, 0x9b, + 0x72, 0xa6, 0x30, 0x65, 0x44, 0x64, 0x89, 0xa8, 0x58, 0x91, 0xca, 0x64, 0xf1, 0x30, 0xd1, 0x09, + 0xc1, 0x4e, 0xce, 0x73, 0x6e, 0xb2, 0x86, 0x3a, 0xaa, 0x05, 0xd1, 0x77, 0x07, 0xd0, 0xcb, 0x23, + 0x92, 0x8e, 0x04, 0x4f, 0x89, 0x94, 0x63, 0xf2, 0xb9, 0x22, 0x52, 0x21, 0x04, 0x1b, 0x58, 0xe4, + 0xd2, 0x77, 0x06, 0xed, 0xd8, 0x1b, 0x9b, 0x18, 0xf9, 0xb0, 0xf9, 0x85, 0x8b, 0xc3, 0x8c, 0x0a, + 0xff, 0xca, 0xc0, 0x89, 0xbd, 0x71, 0x03, 0x51, 0x00, 0xae, 0x22, 0xa2, 0xa4, 0x0c, 0xcf, 0xfc, + 0xf6, 0xc0, 0x89, 0xdd, 0xf1, 0x0a, 0xa3, 0x1d, 0xe8, 0x48, 0x95, 0x51, 0xe6, 0x6f, 0x18, 0x4d, + 0x0d, 0xd0, 0x4d, 0xe8, 0x4a, 0x95, 0xf1, 0x4a, 0xf9, 0x1d, 0x43, 0x5b, 0x64, 0x79, 0x22, 0x84, + 0xdf, 0x5d, 0xf1, 0x44, 0x88, 0x68, 0x0f, 0x6e, 0x9c, 0xb9, 0xa5, 0x9c, 0x73, 0x26, 0x09, 0xea, + 0x83, 0x47, 0x8e, 0xa8, 0x9a, 0xa6, 0x3c, 0x23, 0xbe, 0x33, 0x70, 0xe2, 0xce, 0xd8, 0xd5, 0xc4, + 0x73, 0x9e, 0x91, 0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, 0xf8, 0xfc, 0x44, 0x5b, 0x7f, 0x1f, + 0x36, 0x75, 0xfd, 0x11, 0xcd, 0xd0, 0x9d, 0x35, 0xa2, 0x3f, 0x3b, 0x09, 0xee, 0x9e, 0x97, 0x56, + 0x57, 0x7e, 0xf6, 0xfe, 0xe4, 0x34, 0x6c, 0xfd, 0x3c, 0x0d, 0x5b, 0x5f, 0x97, 0xa1, 0x73, 0xb2, + 0x0c, 0x9d, 0x1f, 0xcb, 0xd0, 0xf9, 0xb5, 0x0c, 0x9d, 0x0f, 0x8f, 0x2f, 0xf7, 0x09, 0x78, 0xd2, + 0x04, 0xfb, 0xad, 0x83, 0xae, 0xf9, 0x53, 0x3f, 0xfa, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x3e, 0xb1, + 0xa6, 0x27, 0x46, 0x04, 0x00, 0x00, } func (m *ExecProcessRequest) Marshal() (dAtA []byte, err error) { @@ -527,6 +609,53 @@ func (m *ShareResponse) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *PidRequest) 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 *PidRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + +func (m *PidResponse) 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 *PidResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Pid != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintShimdiag(dAtA, i, uint64(m.Pid)) + } + if m.XXX_unrecognized != nil { + i += copy(dAtA[i:], m.XXX_unrecognized) + } + return i, nil +} + func encodeVarintShimdiag(dAtA []byte, offset int, v uint64) int { for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -655,6 +784,33 @@ func (m *ShareResponse) Size() (n int) { return n } +func (m *PidRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + +func (m *PidResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pid != 0 { + n += 1 + sovShimdiag(uint64(m.Pid)) + } + if m.XXX_unrecognized != nil { + n += len(m.XXX_unrecognized) + } + return n +} + func sovShimdiag(x uint64) (n int) { for { n++ @@ -740,6 +896,27 @@ func (this *ShareResponse) String() string { }, "") return s } +func (this *PidRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&PidRequest{`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} +func (this *PidResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&PidResponse{`, + `Pid:` + fmt.Sprintf("%v", this.Pid) + `,`, + `XXX_unrecognized:` + fmt.Sprintf("%v", this.XXX_unrecognized) + `,`, + `}`, + }, "") + return s +} func valueToStringShimdiag(v interface{}) string { rv := reflect.ValueOf(v) if rv.IsNil() { @@ -753,6 +930,7 @@ type ShimDiagService interface { DiagExecInHost(ctx context.Context, req *ExecProcessRequest) (*ExecProcessResponse, error) DiagStacks(ctx context.Context, req *StacksRequest) (*StacksResponse, error) DiagShare(ctx context.Context, req *ShareRequest) (*ShareResponse, error) + DiagPid(ctx context.Context, req *PidRequest) (*PidResponse, error) } func RegisterShimDiagService(srv *github_com_containerd_ttrpc.Server, svc ShimDiagService) { @@ -778,6 +956,13 @@ func RegisterShimDiagService(srv *github_com_containerd_ttrpc.Server, svc ShimDi } return svc.DiagShare(ctx, &req) }, + "DiagPid": func(ctx context.Context, unmarshal func(interface{}) error) (interface{}, error) { + var req PidRequest + if err := unmarshal(&req); err != nil { + return nil, err + } + return svc.DiagPid(ctx, &req) + }, }) } @@ -814,6 +999,14 @@ func (c *shimDiagClient) DiagShare(ctx context.Context, req *ShareRequest) (*Sha } return &resp, nil } + +func (c *shimDiagClient) DiagPid(ctx context.Context, req *PidRequest) (*PidResponse, error) { + var resp PidResponse + if err := c.client.Call(ctx, "containerd.runhcs.v1.diag.ShimDiag", "DiagPid", req, &resp); err != nil { + return nil, err + } + return &resp, nil +} func (m *ExecProcessRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1485,6 +1678,133 @@ func (m *ShareResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *PidRequest) 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 ErrIntOverflowShimdiag + } + 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: PidRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PidRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipShimdiag(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthShimdiag + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthShimdiag + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PidResponse) 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 ErrIntOverflowShimdiag + } + 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: PidResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PidResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Pid", wireType) + } + m.Pid = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShimdiag + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Pid |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipShimdiag(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthShimdiag + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthShimdiag + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipShimdiag(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/internal/shimdiag/shimdiag.proto b/internal/shimdiag/shimdiag.proto index 30427fb180..d5ae007716 100644 --- a/internal/shimdiag/shimdiag.proto +++ b/internal/shimdiag/shimdiag.proto @@ -9,6 +9,7 @@ service ShimDiag { rpc DiagExecInHost(ExecProcessRequest) returns (ExecProcessResponse); rpc DiagStacks(StacksRequest) returns (StacksResponse); rpc DiagShare(ShareRequest) returns (ShareResponse); + rpc DiagPid(PidRequest) returns (PidResponse); } message ExecProcessRequest { @@ -40,3 +41,10 @@ message ShareRequest { message ShareResponse { } + +message PidRequest{ +} + +message PidResponse{ + int32 pid = 1; +} \ No newline at end of file