From dd113d1c5f312836e3ff0ae514ed3092025fc6e9 Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Wed, 28 Mar 2018 14:00:40 -0600 Subject: [PATCH] grpc: implement ListProcesses ListProcesses returns a list of running processes inside the container, this function should be called by the runtime in the ps command implementation. fixes #193 Signed-off-by: Julio Montes --- grpc.go | 90 +++++ protocols/grpc/agent.pb.go | 608 ++++++++++++++++++++++++----- protocols/grpc/agent.proto | 13 + protocols/mockserver/mockserver.go | 10 + reaper.go | 31 ++ 5 files changed, 652 insertions(+), 100 deletions(-) diff --git a/grpc.go b/grpc.go index bec73f9419..ef812b6ca3 100644 --- a/grpc.go +++ b/grpc.go @@ -7,11 +7,16 @@ package main import ( + "bytes" + "encoding/json" "fmt" "io/ioutil" "os" + "os/exec" "path/filepath" "regexp" + "strconv" + "strings" "syscall" "time" @@ -536,6 +541,91 @@ func (a *agentGRPC) WaitProcess(ctx context.Context, req *pb.WaitProcessRequest) }, nil } +func getPIDIndex(title string) int { + // looking for PID field in ps title + fields := strings.Fields(title) + for i, f := range fields { + if f == "PID" { + return i + } + } + return -1 +} + +func (a *agentGRPC) ListProcesses(ctx context.Context, req *pb.ListProcessesRequest) (*pb.ListProcessesResponse, error) { + resp := &pb.ListProcessesResponse{} + + c, err := a.sandbox.getContainer(req.ContainerId) + if err != nil { + return resp, err + } + + pids, err := c.container.Processes() + if err != nil { + return resp, err + } + + switch req.Format { + case "table": + case "json": + resp.ProcessList, err = json.Marshal(pids) + return resp, err + default: + return resp, fmt.Errorf("invalid format option") + } + + psArgs := req.Args + if len(psArgs) == 0 { + psArgs = []string{"-ef"} + } + + cmd := exec.Command("ps", psArgs...) + output, err := a.sandbox.subreaper.combinedOutput(cmd) + if err != nil { + return nil, fmt.Errorf("%s: %s", err, output) + } + + lines := strings.Split(string(output), "\n") + + pidIndex := getPIDIndex(lines[0]) + + // PID field not found + if pidIndex == -1 { + return nil, fmt.Errorf("failed to find PID field in ps output") + } + + // append title + var result bytes.Buffer + + result.WriteString(lines[0] + "\n") + + for _, line := range lines[1:] { + if len(line) == 0 { + continue + } + fields := strings.Fields(line) + if pidIndex >= len(fields) { + return nil, fmt.Errorf("missing PID field: %s", line) + } + + p, err := strconv.Atoi(fields[pidIndex]) + if err != nil { + return nil, fmt.Errorf("failed to convert pid to int: %s", fields[pidIndex]) + } + + // appends pid line + for _, pid := range pids { + if pid == p { + result.WriteString(line + "\n") + break + } + } + } + + resp.ProcessList = result.Bytes() + return resp, nil +} + func (a *agentGRPC) RemoveContainer(ctx context.Context, req *pb.RemoveContainerRequest) (*gpb.Empty, error) { ctr, err := a.sandbox.getContainer(req.ContainerId) if err != nil { diff --git a/protocols/grpc/agent.pb.go b/protocols/grpc/agent.pb.go index a109f6e521..78bf75be2d 100644 --- a/protocols/grpc/agent.pb.go +++ b/protocols/grpc/agent.pb.go @@ -17,6 +17,8 @@ SignalProcessRequest WaitProcessRequest WaitProcessResponse + ListProcessesRequest + ListProcessesResponse WriteStreamRequest WriteStreamResponse ReadStreamRequest @@ -332,6 +334,56 @@ func (m *WaitProcessResponse) GetStatus() int32 { return 0 } +// ListProcessesRequest contains the options used to list running processes inside the container +type ListProcessesRequest struct { + ContainerId string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` + Format string `protobuf:"bytes,2,opt,name=format,proto3" json:"format,omitempty"` + Args []string `protobuf:"bytes,3,rep,name=args" json:"args,omitempty"` +} + +func (m *ListProcessesRequest) Reset() { *m = ListProcessesRequest{} } +func (m *ListProcessesRequest) String() string { return proto.CompactTextString(m) } +func (*ListProcessesRequest) ProtoMessage() {} +func (*ListProcessesRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{7} } + +func (m *ListProcessesRequest) GetContainerId() string { + if m != nil { + return m.ContainerId + } + return "" +} + +func (m *ListProcessesRequest) GetFormat() string { + if m != nil { + return m.Format + } + return "" +} + +func (m *ListProcessesRequest) GetArgs() []string { + if m != nil { + return m.Args + } + return nil +} + +// ListProcessesResponse represents the list of running processes inside the container +type ListProcessesResponse struct { + ProcessList []byte `protobuf:"bytes,1,opt,name=process_list,json=processList,proto3" json:"process_list,omitempty"` +} + +func (m *ListProcessesResponse) Reset() { *m = ListProcessesResponse{} } +func (m *ListProcessesResponse) String() string { return proto.CompactTextString(m) } +func (*ListProcessesResponse) ProtoMessage() {} +func (*ListProcessesResponse) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{8} } + +func (m *ListProcessesResponse) GetProcessList() []byte { + if m != nil { + return m.ProcessList + } + return nil +} + type WriteStreamRequest struct { ContainerId string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` ExecId string `protobuf:"bytes,2,opt,name=exec_id,json=execId,proto3" json:"exec_id,omitempty"` @@ -341,7 +393,7 @@ type WriteStreamRequest struct { func (m *WriteStreamRequest) Reset() { *m = WriteStreamRequest{} } func (m *WriteStreamRequest) String() string { return proto.CompactTextString(m) } func (*WriteStreamRequest) ProtoMessage() {} -func (*WriteStreamRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{7} } +func (*WriteStreamRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{9} } func (m *WriteStreamRequest) GetContainerId() string { if m != nil { @@ -371,7 +423,7 @@ type WriteStreamResponse struct { func (m *WriteStreamResponse) Reset() { *m = WriteStreamResponse{} } func (m *WriteStreamResponse) String() string { return proto.CompactTextString(m) } func (*WriteStreamResponse) ProtoMessage() {} -func (*WriteStreamResponse) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{8} } +func (*WriteStreamResponse) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{10} } func (m *WriteStreamResponse) GetLen() uint32 { if m != nil { @@ -389,7 +441,7 @@ type ReadStreamRequest struct { func (m *ReadStreamRequest) Reset() { *m = ReadStreamRequest{} } func (m *ReadStreamRequest) String() string { return proto.CompactTextString(m) } func (*ReadStreamRequest) ProtoMessage() {} -func (*ReadStreamRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{9} } +func (*ReadStreamRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{11} } func (m *ReadStreamRequest) GetContainerId() string { if m != nil { @@ -419,7 +471,7 @@ type ReadStreamResponse struct { func (m *ReadStreamResponse) Reset() { *m = ReadStreamResponse{} } func (m *ReadStreamResponse) String() string { return proto.CompactTextString(m) } func (*ReadStreamResponse) ProtoMessage() {} -func (*ReadStreamResponse) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{10} } +func (*ReadStreamResponse) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{12} } func (m *ReadStreamResponse) GetData() []byte { if m != nil { @@ -436,7 +488,7 @@ type CloseStdinRequest struct { func (m *CloseStdinRequest) Reset() { *m = CloseStdinRequest{} } func (m *CloseStdinRequest) String() string { return proto.CompactTextString(m) } func (*CloseStdinRequest) ProtoMessage() {} -func (*CloseStdinRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{11} } +func (*CloseStdinRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{13} } func (m *CloseStdinRequest) GetContainerId() string { if m != nil { @@ -462,7 +514,7 @@ type TtyWinResizeRequest struct { func (m *TtyWinResizeRequest) Reset() { *m = TtyWinResizeRequest{} } func (m *TtyWinResizeRequest) String() string { return proto.CompactTextString(m) } func (*TtyWinResizeRequest) ProtoMessage() {} -func (*TtyWinResizeRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{12} } +func (*TtyWinResizeRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{14} } func (m *TtyWinResizeRequest) GetContainerId() string { if m != nil { @@ -502,7 +554,7 @@ type CreateSandboxRequest struct { func (m *CreateSandboxRequest) Reset() { *m = CreateSandboxRequest{} } func (m *CreateSandboxRequest) String() string { return proto.CompactTextString(m) } func (*CreateSandboxRequest) ProtoMessage() {} -func (*CreateSandboxRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{13} } +func (*CreateSandboxRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{15} } func (m *CreateSandboxRequest) GetHostname() string { if m != nil { @@ -538,7 +590,7 @@ type DestroySandboxRequest struct { func (m *DestroySandboxRequest) Reset() { *m = DestroySandboxRequest{} } func (m *DestroySandboxRequest) String() string { return proto.CompactTextString(m) } func (*DestroySandboxRequest) ProtoMessage() {} -func (*DestroySandboxRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{14} } +func (*DestroySandboxRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{16} } type IPAddress struct { Family IPFamily `protobuf:"varint,1,opt,name=family,proto3,enum=grpc.IPFamily" json:"family,omitempty"` @@ -549,7 +601,7 @@ type IPAddress struct { func (m *IPAddress) Reset() { *m = IPAddress{} } func (m *IPAddress) String() string { return proto.CompactTextString(m) } func (*IPAddress) ProtoMessage() {} -func (*IPAddress) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{15} } +func (*IPAddress) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{17} } func (m *IPAddress) GetFamily() IPFamily { if m != nil { @@ -583,7 +635,7 @@ type Interface struct { func (m *Interface) Reset() { *m = Interface{} } func (m *Interface) String() string { return proto.CompactTextString(m) } func (*Interface) ProtoMessage() {} -func (*Interface) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{16} } +func (*Interface) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{18} } func (m *Interface) GetDevice() string { if m != nil { @@ -631,7 +683,7 @@ type Route struct { func (m *Route) Reset() { *m = Route{} } func (m *Route) String() string { return proto.CompactTextString(m) } func (*Route) ProtoMessage() {} -func (*Route) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{17} } +func (*Route) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{19} } func (m *Route) GetDest() string { if m != nil { @@ -675,7 +727,7 @@ type Routes struct { func (m *Routes) Reset() { *m = Routes{} } func (m *Routes) String() string { return proto.CompactTextString(m) } func (*Routes) ProtoMessage() {} -func (*Routes) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{18} } +func (*Routes) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{20} } func (m *Routes) GetRoutes() []*Route { if m != nil { @@ -691,7 +743,7 @@ type UpdateInterfaceRequest struct { func (m *UpdateInterfaceRequest) Reset() { *m = UpdateInterfaceRequest{} } func (m *UpdateInterfaceRequest) String() string { return proto.CompactTextString(m) } func (*UpdateInterfaceRequest) ProtoMessage() {} -func (*UpdateInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{19} } +func (*UpdateInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{21} } func (m *UpdateInterfaceRequest) GetInterface() *Interface { if m != nil { @@ -707,7 +759,7 @@ type AddInterfaceRequest struct { func (m *AddInterfaceRequest) Reset() { *m = AddInterfaceRequest{} } func (m *AddInterfaceRequest) String() string { return proto.CompactTextString(m) } func (*AddInterfaceRequest) ProtoMessage() {} -func (*AddInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{20} } +func (*AddInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{22} } func (m *AddInterfaceRequest) GetInterface() *Interface { if m != nil { @@ -723,7 +775,7 @@ type RemoveInterfaceRequest struct { func (m *RemoveInterfaceRequest) Reset() { *m = RemoveInterfaceRequest{} } func (m *RemoveInterfaceRequest) String() string { return proto.CompactTextString(m) } func (*RemoveInterfaceRequest) ProtoMessage() {} -func (*RemoveInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{21} } +func (*RemoveInterfaceRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{23} } func (m *RemoveInterfaceRequest) GetInterface() *Interface { if m != nil { @@ -739,7 +791,7 @@ type UpdateRoutesRequest struct { func (m *UpdateRoutesRequest) Reset() { *m = UpdateRoutesRequest{} } func (m *UpdateRoutesRequest) String() string { return proto.CompactTextString(m) } func (*UpdateRoutesRequest) ProtoMessage() {} -func (*UpdateRoutesRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{22} } +func (*UpdateRoutesRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{24} } func (m *UpdateRoutesRequest) GetRoutes() *Routes { if m != nil { @@ -754,7 +806,7 @@ type OnlineCPUMemRequest struct { func (m *OnlineCPUMemRequest) Reset() { *m = OnlineCPUMemRequest{} } func (m *OnlineCPUMemRequest) String() string { return proto.CompactTextString(m) } func (*OnlineCPUMemRequest) ProtoMessage() {} -func (*OnlineCPUMemRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{23} } +func (*OnlineCPUMemRequest) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{25} } // Storage represents both the rootfs of the container, and any volume that // could have been defined through the Mount list of the OCI specification. @@ -789,7 +841,7 @@ type Storage struct { func (m *Storage) Reset() { *m = Storage{} } func (m *Storage) String() string { return proto.CompactTextString(m) } func (*Storage) ProtoMessage() {} -func (*Storage) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{24} } +func (*Storage) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{26} } func (m *Storage) GetDriver() string { if m != nil { @@ -872,7 +924,7 @@ type Device struct { func (m *Device) Reset() { *m = Device{} } func (m *Device) String() string { return proto.CompactTextString(m) } func (*Device) ProtoMessage() {} -func (*Device) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{25} } +func (*Device) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{27} } func (m *Device) GetId() string { if m != nil { @@ -918,7 +970,7 @@ type StringUser struct { func (m *StringUser) Reset() { *m = StringUser{} } func (m *StringUser) String() string { return proto.CompactTextString(m) } func (*StringUser) ProtoMessage() {} -func (*StringUser) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{26} } +func (*StringUser) Descriptor() ([]byte, []int) { return fileDescriptorAgent, []int{28} } func (m *StringUser) GetUid() string { if m != nil { @@ -949,6 +1001,8 @@ func init() { proto.RegisterType((*SignalProcessRequest)(nil), "grpc.SignalProcessRequest") proto.RegisterType((*WaitProcessRequest)(nil), "grpc.WaitProcessRequest") proto.RegisterType((*WaitProcessResponse)(nil), "grpc.WaitProcessResponse") + proto.RegisterType((*ListProcessesRequest)(nil), "grpc.ListProcessesRequest") + proto.RegisterType((*ListProcessesResponse)(nil), "grpc.ListProcessesResponse") proto.RegisterType((*WriteStreamRequest)(nil), "grpc.WriteStreamRequest") proto.RegisterType((*WriteStreamResponse)(nil), "grpc.WriteStreamResponse") proto.RegisterType((*ReadStreamRequest)(nil), "grpc.ReadStreamRequest") @@ -996,6 +1050,7 @@ type AgentServiceClient interface { ExecProcess(ctx context.Context, in *ExecProcessRequest, opts ...grpc1.CallOption) (*google_protobuf2.Empty, error) SignalProcess(ctx context.Context, in *SignalProcessRequest, opts ...grpc1.CallOption) (*google_protobuf2.Empty, error) WaitProcess(ctx context.Context, in *WaitProcessRequest, opts ...grpc1.CallOption) (*WaitProcessResponse, error) + ListProcesses(ctx context.Context, in *ListProcessesRequest, opts ...grpc1.CallOption) (*ListProcessesResponse, error) // stdio WriteStdin(ctx context.Context, in *WriteStreamRequest, opts ...grpc1.CallOption) (*WriteStreamResponse, error) ReadStdout(ctx context.Context, in *ReadStreamRequest, opts ...grpc1.CallOption) (*ReadStreamResponse, error) @@ -1075,6 +1130,15 @@ func (c *agentServiceClient) WaitProcess(ctx context.Context, in *WaitProcessReq return out, nil } +func (c *agentServiceClient) ListProcesses(ctx context.Context, in *ListProcessesRequest, opts ...grpc1.CallOption) (*ListProcessesResponse, error) { + out := new(ListProcessesResponse) + err := grpc1.Invoke(ctx, "/grpc.AgentService/ListProcesses", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *agentServiceClient) WriteStdin(ctx context.Context, in *WriteStreamRequest, opts ...grpc1.CallOption) (*WriteStreamResponse, error) { out := new(WriteStreamResponse) err := grpc1.Invoke(ctx, "/grpc.AgentService/WriteStdin", in, out, c.cc, opts...) @@ -1199,6 +1263,7 @@ type AgentServiceServer interface { ExecProcess(context.Context, *ExecProcessRequest) (*google_protobuf2.Empty, error) SignalProcess(context.Context, *SignalProcessRequest) (*google_protobuf2.Empty, error) WaitProcess(context.Context, *WaitProcessRequest) (*WaitProcessResponse, error) + ListProcesses(context.Context, *ListProcessesRequest) (*ListProcessesResponse, error) // stdio WriteStdin(context.Context, *WriteStreamRequest) (*WriteStreamResponse, error) ReadStdout(context.Context, *ReadStreamRequest) (*ReadStreamResponse, error) @@ -1328,6 +1393,24 @@ func _AgentService_WaitProcess_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _AgentService_ListProcesses_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc1.UnaryServerInterceptor) (interface{}, error) { + in := new(ListProcessesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AgentServiceServer).ListProcesses(ctx, in) + } + info := &grpc1.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.AgentService/ListProcesses", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AgentServiceServer).ListProcesses(ctx, req.(*ListProcessesRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _AgentService_WriteStdin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc1.UnaryServerInterceptor) (interface{}, error) { in := new(WriteStreamRequest) if err := dec(in); err != nil { @@ -1572,6 +1655,10 @@ var _AgentService_serviceDesc = grpc1.ServiceDesc{ MethodName: "WaitProcess", Handler: _AgentService_WaitProcess_Handler, }, + { + MethodName: "ListProcesses", + Handler: _AgentService_ListProcesses_Handler, + }, { MethodName: "WriteStdin", Handler: _AgentService_WriteStdin_Handler, @@ -1890,6 +1977,75 @@ func (m *WaitProcessResponse) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *ListProcessesRequest) 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 *ListProcessesRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ContainerId) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintAgent(dAtA, i, uint64(len(m.ContainerId))) + i += copy(dAtA[i:], m.ContainerId) + } + if len(m.Format) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintAgent(dAtA, i, uint64(len(m.Format))) + i += copy(dAtA[i:], m.Format) + } + if len(m.Args) > 0 { + for _, s := range m.Args { + dAtA[i] = 0x1a + i++ + l = len(s) + for l >= 1<<7 { + dAtA[i] = uint8(uint64(l)&0x7f | 0x80) + l >>= 7 + i++ + } + dAtA[i] = uint8(l) + i++ + i += copy(dAtA[i:], s) + } + } + return i, nil +} + +func (m *ListProcessesResponse) 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 *ListProcessesResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ProcessList) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintAgent(dAtA, i, uint64(len(m.ProcessList))) + i += copy(dAtA[i:], m.ProcessList) + } + return i, nil +} + func (m *WriteStreamRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2754,6 +2910,36 @@ func (m *WaitProcessResponse) Size() (n int) { return n } +func (m *ListProcessesRequest) Size() (n int) { + var l int + _ = l + l = len(m.ContainerId) + if l > 0 { + n += 1 + l + sovAgent(uint64(l)) + } + l = len(m.Format) + if l > 0 { + n += 1 + l + sovAgent(uint64(l)) + } + if len(m.Args) > 0 { + for _, s := range m.Args { + l = len(s) + n += 1 + l + sovAgent(uint64(l)) + } + } + return n +} + +func (m *ListProcessesResponse) Size() (n int) { + var l int + _ = l + l = len(m.ProcessList) + if l > 0 { + n += 1 + l + sovAgent(uint64(l)) + } + return n +} + func (m *WriteStreamRequest) Size() (n int) { var l int _ = l @@ -3986,6 +4172,224 @@ func (m *WaitProcessResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *ListProcessesRequest) 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 ErrIntOverflowAgent + } + 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: ListProcessesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListProcessesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContainerId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAgent + } + 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 ErrInvalidLengthAgent + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContainerId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAgent + } + 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 ErrInvalidLengthAgent + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Format = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Args", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAgent + } + 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 ErrInvalidLengthAgent + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Args = append(m.Args, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAgent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAgent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListProcessesResponse) 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 ErrIntOverflowAgent + } + 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: ListProcessesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListProcessesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProcessList", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAgent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAgent + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProcessList = append(m.ProcessList[:0], dAtA[iNdEx:postIndex]...) + if m.ProcessList == nil { + m.ProcessList = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAgent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthAgent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *WriteStreamRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -6491,85 +6895,89 @@ var ( func init() { proto.RegisterFile("agent.proto", fileDescriptorAgent) } var fileDescriptorAgent = []byte{ - // 1271 bytes of a gzipped FileDescriptorProto + // 1339 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xdf, 0x6e, 0x1b, 0xc5, - 0x17, 0xfe, 0x6d, 0x9c, 0x38, 0xf1, 0xb1, 0x9d, 0xa4, 0x93, 0x36, 0xd9, 0x9f, 0x5b, 0x95, 0xb0, - 0x40, 0x1b, 0x90, 0x9a, 0x8a, 0x80, 0x40, 0x2a, 0x42, 0x25, 0x4d, 0x4b, 0x94, 0x0b, 0x14, 0x6b, - 0x4c, 0x54, 0xee, 0xa2, 0xe9, 0xee, 0xc4, 0x59, 0xf0, 0xee, 0x2c, 0x33, 0xb3, 0x4e, 0x4d, 0xef, - 0x79, 0x02, 0x1e, 0x83, 0x3b, 0x5e, 0x80, 0x4b, 0x2e, 0x79, 0x04, 0xd4, 0xa7, 0xe0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, 0xd6, 0xde, 0x04, 0xeb, 0x53, 0xb8, - 0x71, 0x34, 0x60, 0x82, 0xf6, 0x64, 0x14, 0xa7, 0x8b, 0x38, 0x9b, 0x57, 0xb0, 0xf5, 0xad, 0x1c, - 0x3d, 0x57, 0x60, 0x22, 0xfe, 0x89, 0x2e, 0xa8, 0x3e, 0xce, 0xae, 0x5c, 0x7d, 0x9c, 0x5d, 0xa9, - 0x93, 0x0e, 0xd9, 0x20, 0x4f, 0x52, 0x7d, 0xcd, 0xdb, 0xd8, 0x5a, 0xc1, 0x2f, 0x1e, 0xdc, 0x34, - 0x33, 0xb1, 0x47, 0xd2, 0xe8, 0x05, 0x7b, 0xe9, 0xd2, 0x77, 0x60, 0xed, 0x92, 0x09, 0x99, 0x92, - 0x84, 0xda, 0xd4, 0x85, 0xad, 0xe0, 0xa3, 0x54, 0xf8, 0x4b, 0xbb, 0xb5, 0xbd, 0x06, 0x56, 0xcb, - 0xd2, 0xa0, 0xaa, 0xbd, 0x79, 0x50, 0xbd, 0x07, 0x6d, 0x61, 0x52, 0x9d, 0x67, 0xb1, 0x82, 0x51, - 0x84, 0xd6, 0x70, 0xcb, 0x3a, 0xbb, 0xca, 0x17, 0xec, 0xc0, 0xad, 0xa7, 0x54, 0x48, 0xce, 0x46, - 0x65, 0x5a, 0x01, 0x81, 0xc6, 0x49, 0xf7, 0x30, 0x8a, 0x38, 0x15, 0x02, 0xdd, 0x83, 0xfa, 0x05, - 0x49, 0xe2, 0xc1, 0x48, 0x33, 0x5c, 0x3f, 0x58, 0x37, 0x39, 0x4f, 0xba, 0x5f, 0x6b, 0x2f, 0xb6, - 0x51, 0x35, 0x84, 0x88, 0xf9, 0x8b, 0xed, 0x93, 0x33, 0xd5, 0x01, 0x27, 0x44, 0xfc, 0xa0, 0x3b, - 0xd5, 0xc0, 0x7a, 0xad, 0x5a, 0xd2, 0x38, 0x49, 0x25, 0xe5, 0x17, 0x24, 0xd4, 0x4f, 0xc4, 0x4c, - 0x63, 0xd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+ 0x7b, 0xe6, 0x83, 0x26, 0x19, 0xd2, 0x54, 0xed, 0x64, 0x82, 0x2b, 0x8e, 0xe6, 0x87, 0x22, 0x1b, + 0x74, 0x1a, 0x7c, 0xc0, 0xac, 0xa3, 0x73, 0x63, 0xc8, 0xf9, 0x70, 0x44, 0xef, 0x1b, 0xeb, 0x59, + 0x7e, 0x72, 0x9f, 0x26, 0x99, 0xba, 0xb0, 0xc1, 0xe8, 0xaf, 0x00, 0x36, 0xf6, 0x05, 0x25, 0x8a, + 0xee, 0xf3, 0x54, 0x11, 0x96, 0x52, 0x81, 0xe9, 0x0f, 0x39, 0x95, 0x0a, 0xdd, 0x86, 0xd6, 0xc0, + 0xfb, 0xfa, 0x2c, 0x0e, 0x83, 0xad, 0x60, 0xbb, 0x81, 0x9b, 0x85, 0xef, 0x30, 0x46, 0x9b, 0xb0, + 0x48, 0x9f, 0xd3, 0x81, 0x8e, 0xce, 0x99, 0x68, 0x5d, 0x9b, 0x87, 0x31, 0xfa, 0x00, 0x9a, 0x52, + 0x09, 0x96, 0x0e, 0xfb, 0xb9, 0xa4, 0x22, 0xac, 0x6d, 0x05, 0xdb, 0xcd, 0xdd, 0xd5, 0x1d, 0x4d, + 0x6d, 0xa7, 0x67, 0x02, 0xc7, 0x92, 0x0a, 0x0c, 0xb2, 0x58, 0xa3, 0x3b, 0xb0, 0x18, 0xd3, 0x33, + 0x36, 0xa0, 0x32, 0x9c, 0xdf, 0xaa, 0x6d, 0x37, 0x77, 0x5b, 0x76, 0xfb, 0x63, 0xe3, 0xc4, 0x3e, + 0x88, 0xde, 0x83, 0x25, 0xa9, 0xb8, 0x20, 0x43, 0x2a, 0xc3, 0x05, 0xb3, 0xb1, 0xed, 0x71, 0x8d, + 0x17, 0x17, 0x61, 0x74, 0x13, 0x6a, 0x47, 0xfb, 0x87, 0x61, 0xdd, 0x64, 0x07, 0xb7, 0x2b, 0xa3, + 0x03, 0xac, 0xdd, 0xd1, 0x03, 0xb8, 0xde, 0x53,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 0x1f, 0xf5, + 0x12, 0xdd, 0x81, 0x65, 0x12, 0xc7, 0x4c, 0xff, 0x9d, 0x8c, 0x0e, 0x58, 0xec, 0x9f, 0xcd, 0x29, + 0xef, 0xfb, 0x1d, 0x58, 0xf2, 0x93, 0x04, 0xd5, 0x61, 0xee, 0xec, 0xa3, 0xd5, 0xff, 0x99, 0xdf, + 0x8f, 0x57, 0x83, 0xdd, 0x9f, 0x01, 0x5a, 0x7b, 0x5a, 0x2b, 0xf7, 0xa8, 0x30, 0x4d, 0x38, 0x80, + 0x95, 0x29, 0xf5, 0x8b, 0x6e, 0xda, 0x5b, 0x50, 0x2d, 0x8a, 0x3b, 0x1b, 0x3b, 0x56, 0x4d, 0xef, + 0x78, 0x35, 0xbd, 0xf3, 0x44, 0xab, 0x69, 0xf4, 0x04, 0x96, 0xcb, 0x62, 0x12, 0xdd, 0xf0, 0x93, + 0xb4, 0x42, 0x62, 0xce, 0x84, 0x39, 0x80, 0x95, 0x29, 0x5d, 0xe9, 0xf9, 0x54, 0xcb, 0xcd, 0x99, + 0x40, 0x0f, 0xa1, 0x39, 0x21, 0x24, 0x51, 0x68, 0x41, 0x2e, 0x6b, 0xcb, 0x99, 0x00, 0xfb, 0xd0, + 0x2e, 0x69, 0x3b, 0xd4, 0x71, 0xf5, 0x54, 0x08, 0xbe, 0x99, 0x20, 0x8f, 0xa0, 0x39, 0x21, 0xb1, + 0x3c, 0x8b, 0xcb, 0x3a, 0xae, 0xf3, 0xff, 0x8a, 0x88, 0x7b, 0xcc, 0xbf, 0x84, 0x76, 0x49, 0x10, + 0x79, 0x22, 0x55, 0x62, 0xac, 0x73, 0xa3, 0x32, 0xe6, 0x90, 0xf6, 0x00, 0x9c, 0x70, 0x89, 0x59, + 0x5a, 0x90, 0xb9, 0x24, 0x98, 0x0a, 0x32, 0x15, 0x22, 0xe7, 0x21, 0x80, 0xd5, 0x1b, 0x31, 0xcf, + 0x15, 0xda, 0xf4, 0x47, 0x33, 0x25, 0x72, 0x3a, 0xe1, 0xe5, 0xc0, 0x25, 0x00, 0x2a, 0xc4, 0xeb, + 0x00, 0x7c, 0x06, 0x30, 0xd6, 0x31, 0x1e, 0xe0, 0x92, 0xb2, 0x99, 0x79, 0x22, 0x7b, 0xd0, 0x9a, + 0x54, 0x2d, 0xc8, 0xd5, 0x5a, 0xa1, 0x64, 0x66, 0x42, 0x3c, 0x80, 0xd6, 0xe4, 0x70, 0xf7, 0x10, + 0x15, 0x03, 0xbf, 0x33, 0x3d, 0x94, 0xd1, 0xe7, 0xb0, 0x32, 0xf5, 0xc2, 0xf8, 0xfb, 0x5d, 0xfd, + 0xf0, 0x54, 0x22, 0x4c, 0x3d, 0x0a, 0xe5, 0x2f, 0xe4, 0x9f, 0x11, 0x3e, 0x81, 0xd6, 0xe4, 0x6b, + 0xe0, 0xf9, 0x57, 0xbc, 0x10, 0x9d, 0xd2, 0x8b, 0xa0, 0x3f, 0x89, 0x92, 0xe6, 0xf2, 0x37, 0xb1, + 0x4a, 0x88, 0xbd, 0x6a, 0x50, 0x94, 0x25, 0x92, 0x1f, 0x14, 0x95, 0xc2, 0xe9, 0x55, 0xe7, 0x38, + 0xf9, 0x2a, 0xf9, 0x22, 0x2a, 0x5e, 0xaa, 0x59, 0x10, 0x8f, 0x5a, 0xbf, 0xbf, 0xbc, 0x15, 0xfc, + 0xf1, 0xf2, 0x56, 0xf0, 0xe7, 0xcb, 0x5b, 0xc1, 0xb3, 0xba, 0x89, 0x7e, 0xf8, 0x77, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xd7, 0x47, 0xb8, 0xf5, 0x4c, 0x10, 0x00, 0x00, } diff --git a/protocols/grpc/agent.proto b/protocols/grpc/agent.proto index 75e57bfff7..e92bbfa698 100644 --- a/protocols/grpc/agent.proto +++ b/protocols/grpc/agent.proto @@ -28,6 +28,7 @@ service AgentService { rpc ExecProcess(ExecProcessRequest) returns (google.protobuf.Empty); rpc SignalProcess(SignalProcessRequest) returns (google.protobuf.Empty); rpc WaitProcess(WaitProcessRequest) returns (WaitProcessResponse); // wait & reap like waitpid(2) + rpc ListProcesses(ListProcessesRequest) returns (ListProcessesResponse); // stdio rpc WriteStdin(WriteStreamRequest) returns (WriteStreamResponse); @@ -97,6 +98,18 @@ message WaitProcessResponse { int32 status = 1; } +// ListProcessesRequest contains the options used to list running processes inside the container +message ListProcessesRequest { + string container_id = 1; + string format = 2; + repeated string args = 3; +} + +// ListProcessesResponse represents the list of running processes inside the container +message ListProcessesResponse { + bytes process_list = 1; +} + message WriteStreamRequest { string container_id = 1; string exec_id = 2; diff --git a/protocols/mockserver/mockserver.go b/protocols/mockserver/mockserver.go index ddce57f674..3492b51a4d 100644 --- a/protocols/mockserver/mockserver.go +++ b/protocols/mockserver/mockserver.go @@ -335,3 +335,13 @@ func (m *mockServer) OnlineCPUMem(ctx context.Context, req *pb.OnlineCPUMemReque return &types.Empty{}, nil } + +func (m *mockServer) ListProcesses(ctx context.Context, req *pb.ListProcessesRequest) (*pb.ListProcessesResponse, error) { + mockLock.RLock() + defer mockLock.RUnlock() + if err := m.podExist(); err != nil { + return nil, err + } + + return &pb.ListProcessesResponse{}, nil +} diff --git a/reaper.go b/reaper.go index 12ad0f70f0..921629d516 100644 --- a/reaper.go +++ b/reaper.go @@ -7,6 +7,9 @@ package main import ( + "bytes" + "errors" + "fmt" "os" "os/exec" "sync" @@ -157,6 +160,34 @@ func (r *reaper) wait(exitCodeCh <-chan int, proc waitProcess) (int, error) { return exitCode, nil } +// run runs the exec command and waits for it, returns once the command +// has been reaped +func (r *reaper) run(c *exec.Cmd) error { + exitCodeCh, err := r.start(c) + if err != nil { + return fmt.Errorf("reaper: Could not start process: %v", err) + } + _, err = r.wait(exitCodeCh, (*reaperOSProcess)(c.Process)) + return err +} + +// combinedOutput combines command's stdout and stderr in one buffer, +// returns once the command has been reaped +func (r *reaper) combinedOutput(c *exec.Cmd) ([]byte, error) { + if c.Stdout != nil { + return nil, errors.New("reaper: Stdout already set") + } + if c.Stderr != nil { + return nil, errors.New("reaper: Stderr already set") + } + + var b bytes.Buffer + c.Stdout = &b + c.Stderr = &b + err := r.run(c) + return b.Bytes(), err +} + type waitProcess interface { wait() }