From c190e91bfecff46abf606c2fbf17f7f5826d5488 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 | 95 +++++ grpc_test.go | 24 ++ mockreaper.go | 29 +- protocols/grpc/agent.pb.go | 614 ++++++++++++++++++++++++----- protocols/grpc/agent.proto | 13 + protocols/mockserver/mockserver.go | 10 + reaper.go | 33 ++ 7 files changed, 714 insertions(+), 104 deletions(-) diff --git a/grpc.go b/grpc.go index 00e0c9d49b..0011cfc36d 100644 --- a/grpc.go +++ b/grpc.go @@ -7,11 +7,15 @@ package main import ( + "bytes" + "encoding/json" "fmt" "io/ioutil" "os" + "os/exec" "path/filepath" "regexp" + "strconv" "strings" "sync" "syscall" @@ -623,6 +627,97 @@ 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 + } + + // Get the list of processes that are running inside the containers. + // the PIDs match with the system PIDs, not with container's namespace + 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"} + } + + // All container's processes are visibles from agent's namespace. + // pids already contains the list of processes that are running + // inside a container, now we have to use that list to filter + // ps output and return just container's processes + 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/grpc_test.go b/grpc_test.go index ddddf2a0d9..1e87d5ba51 100644 --- a/grpc_test.go +++ b/grpc_test.go @@ -155,3 +155,27 @@ func TestOnlineCPUMem(t *testing.T) { _, err = a.OnlineCPUMem(context.TODO(), req) assert.NoError(err) } + +func TestGetPIDIndex(t *testing.T) { + assert := assert.New(t) + + title := "UID PID PPID C STIME TTY TIME CMD" + pidIndex := 1 + index := getPIDIndex(title) + assert.Equal(pidIndex, index) + + title = "PID PPID C STIME TTY TIME CMD" + pidIndex = 0 + index = getPIDIndex(title) + assert.Equal(pidIndex, index) + + title = "PPID C STIME TTY TIME CMD PID" + pidIndex = 6 + index = getPIDIndex(title) + assert.Equal(pidIndex, index) + + title = "PPID C STIME TTY TIME CMD" + pidIndex = -1 + index = getPIDIndex(title) + assert.Equal(pidIndex, index) +} diff --git a/mockreaper.go b/mockreaper.go index 67178d61f3..16a977272b 100644 --- a/mockreaper.go +++ b/mockreaper.go @@ -6,7 +6,12 @@ package main -import "os/exec" +import ( + "bytes" + "errors" + "fmt" + "os/exec" +) type mockreaper struct { } @@ -41,3 +46,25 @@ func (r *mockreaper) lock() { func (r *mockreaper) unlock() { } + +func (r *mockreaper) run(c *exec.Cmd) error { + if err := c.Run(); err != nil { + return fmt.Errorf("reaper: Could not start process: %v", err) + } + return nil +} + +func (r *mockreaper) 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 +} diff --git a/protocols/grpc/agent.pb.go b/protocols/grpc/agent.pb.go index 7b5fc73b5f..d70011c1a2 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 { @@ -760,7 +812,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} } func (m *OnlineCPUMemRequest) GetWait() bool { if m != nil { @@ -809,7 +861,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 { @@ -892,7 +944,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 { @@ -938,7 +990,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 { @@ -969,6 +1021,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") @@ -1016,6 +1070,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) @@ -1095,6 +1150,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...) @@ -1219,6 +1283,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) @@ -1348,6 +1413,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 { @@ -1592,6 +1675,10 @@ var _AgentService_serviceDesc = grpc1.ServiceDesc{ MethodName: "WaitProcess", Handler: _AgentService_WaitProcess_Handler, }, + { + MethodName: "ListProcesses", + Handler: _AgentService_ListProcesses_Handler, + }, { MethodName: "WriteStdin", Handler: _AgentService_WriteStdin_Handler, @@ -1910,6 +1997,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) @@ -2789,6 +2945,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 @@ -4027,6 +4213,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 @@ -6571,87 +6975,91 @@ var ( func init() { proto.RegisterFile("agent.proto", fileDescriptorAgent) } var fileDescriptorAgent = []byte{ - // 1297 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, 0x75, 0x4b, 0x94, 0x0b, 0x14, 0x6b, - 0x4c, 0x54, 0xee, 0xac, 0xc9, 0xee, 0xc4, 0x59, 0xf0, 0xee, 0x2c, 0x33, 0xb3, 0x49, 0x43, 0xef, - 0x79, 0x02, 0x1e, 0x83, 0x3b, 0x5e, 0x80, 0x4b, 0x2e, 0x79, 0x04, 0xd4, 0xa7, 0xe0, 0x12, 0xcd, - 0xbf, 0xb5, 0xd7, 0x5e, 0x17, 0xa9, 0xb5, 0xc4, 0x95, 0xe7, 0x9c, 0x33, 0xf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 0xd6, 0xdc, 0xd8, 0x41, 0x75, 0x58, - 0xba, 0xfc, 0x74, 0xf3, 0x7f, 0xfa, 0xf7, 0xb3, 0x4d, 0xef, 0xe0, 0xf7, 0x06, 0xb4, 0x0e, 0x95, - 0x6a, 0xed, 0x53, 0xae, 0x9b, 0x70, 0x04, 0x1b, 0x53, 0x3a, 0x14, 0xdd, 0x31, 0x47, 0xa6, 0x5a, - 0x9e, 0x76, 0xb6, 0xf7, 0x8d, 0xae, 0xdd, 0x77, 0xba, 0x76, 0xff, 0x99, 0xd2, 0xb5, 0xe8, 0x19, - 0xac, 0x97, 0x65, 0x1d, 0xba, 0xed, 0xc6, 0x6e, 0x85, 0xd8, 0x9b, 0x0b, 0x73, 0x04, 0x1b, 0x53, - 0x0a, 0xcf, 0xf1, 0xa9, 0x16, 0x7e, 0x73, 0x81, 0x1e, 0x43, 0x73, 0x42, 0xd2, 0x21, 0xdf, 0x80, - 0xcc, 0xaa, 0xbc, 0xb9, 0x00, 0x5d, 0x68, 0x97, 0x54, 0x16, 0xea, 0xd8, 0x7a, 0x2a, 0xa4, 0xd7, - 0x5c, 0x90, 0x27, 0xd0, 0x9c, 0x10, 0x3b, 0x8e, 0xc5, 0xac, 0xa2, 0xea, 0xfc, 0xbf, 0x22, 0x62, - 0x5f, 0xfe, 0x43, 0x00, 0xab, 0x4d, 0xa2, 0x38, 0x2d, 0x20, 0x66, 0x34, 0x51, 0x01, 0x51, 0xa1, - 0x63, 0x1e, 0x03, 0x18, 0x49, 0x11, 0xb1, 0x5c, 0xa2, 0x1d, 0xd7, 0xd0, 0x29, 0x1d, 0xd3, 0xf1, - 0x67, 0x03, 0x33, 0x00, 0x94, 0xf3, 0x37, 0x01, 0xf8, 0x12, 0x60, 0x2c, 0x55, 0x1c, 0xc0, 0x8c, - 0x78, 0x99, 0xdb, 0xc7, 0x43, 0x68, 0x4d, 0x0a, 0x13, 0x64, 0x6b, 0xad, 0x10, 0x2b, 0x73, 0x21, - 0x1e, 0x41, 0x6b, 0x72, 0x7e, 0x3b, 0x88, 0x8a, 0x99, 0xde, 0x99, 0x9e, 0xbb, 0xe8, 0x2b, 0xd8, - 0x98, 0x7a, 0x44, 0xdc, 0xa9, 0xac, 0x7e, 0x5b, 0x2a, 0x11, 0xa6, 0xe6, 0x7e, 0xf9, 0x5c, 0xff, - 0x3b, 0xc2, 0xe7, 0xd0, 0x9a, 0x1c, 0xf8, 0x8e, 0x7f, 0xc5, 0x23, 0xd0, 0x29, 0x0d, 0x7d, 0x75, - 0x90, 0x4b, 0xb2, 0xca, 0x1d, 0xe4, 0x2a, 0xad, 0xf5, 0xba, 0xeb, 0x5d, 0x56, 0x41, 0xee, 0x7a, - 0x57, 0x6a, 0xa3, 0xd7, 0x7d, 0xc7, 0xc9, 0x87, 0xc7, 0x15, 0x51, 0xf1, 0x18, 0xcd, 0x83, 0x78, - 0xd2, 0xfa, 0xe3, 0xd5, 0x5d, 0xef, 0xcf, 0x57, 0x77, 0xbd, 0xbf, 0x5e, 0xdd, 0xf5, 0xce, 0xea, - 0x3a, 0xfa, 0xc9, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x8b, 0xb0, 0x9a, 0x8c, 0x0f, 0x00, - 0x00, + // 1367 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x5f, 0x6f, 0x1b, 0xc5, + 0x16, 0xbf, 0x1b, 0x3b, 0x4e, 0x7c, 0x6c, 0x27, 0xe9, 0x24, 0x4d, 0xf6, 0xba, 0x55, 0x6f, 0xba, + 0xf7, 0xde, 0x36, 0x20, 0x35, 0x15, 0x01, 0x81, 0x54, 0x84, 0x4a, 0xea, 0x96, 0x10, 0x09, 0x14, + 0x6b, 0x4c, 0x54, 0xde, 0xac, 0xc9, 0xee, 0xc4, 0x59, 0xf0, 0xee, 0x2c, 0x33, 0xb3, 0x49, 0x43, + 0xdf, 0x79, 0xe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0a, 0xc9, 0xd9, 0x65, 0x19, 0x56, 0x40, 0xa0, 0x79, 0xd8, 0xdf, 0x8f, + 0x22, 0x4e, 0x85, 0x40, 0xf7, 0xa0, 0x71, 0x4a, 0x92, 0x78, 0x7c, 0xa9, 0x11, 0xae, 0xec, 0xad, + 0x98, 0x98, 0x87, 0xfd, 0xcf, 0xb4, 0x16, 0x5b, 0xab, 0xea, 0x93, 0xc4, 0xfc, 0x62, 0xf3, 0xe4, + 0x44, 0x75, 0xc1, 0x09, 0x11, 0xdf, 0xea, 0x4c, 0x35, 0xb1, 0x5e, 0xab, 0x94, 0x34, 0x0f, 0x53, + 0x49, 0xf9, 0x29, 0x09, 0xf5, 0x2b, 0x36, 0x03, 0xc3, 0x66, 0xc1, 0x4a, 0xea, 0x4f, 0x9d, 0x1b, + 0xe3, 0x50, 0xaf, 0x55, 0x8b, 0x2c, 0xc0, 0x15, 0x89, 0x58, 0x75, 0xa0, 0xac, 0x01, 0x4f, 0xef, + 0x51, 0xa9, 0x4c, 0x64, 0xae, 0x73, 0x50, 0xc7, 0x6a, 0xa9, 0x02, 0x9e, 0x5d, 0xa8, 0x0d, 0xfe, + 0xa2, 0x09, 0x68, 0xa4, 0xe0, 0x25, 0x2c, 0x62, 0x96, 0x4b, 0x53, 0x94, 0xd4, 0xbe, 0xdb, 0x26, + 0xd6, 0x6b, 0x75, 0xc2, 0x11, 0x91, 0xf4, 0x82, 0x5c, 0xba, 0x13, 0x5a, 0x71, 0x0a, 0x7f, 0xad, + 0x84, 0x5f, 0x75, 0x27, 0x96, 0xf3, 0x90, 0xea, 0xd8, 0x4d, 0x6c, 0x25, 0xb4, 0x01, 0x8b, 0x22, + 0x64, 0x19, 0xd5, 0xd1, 0x3b, 0xd8, 0x08, 0xc1, 0x03, 0x68, 0xe8, 0xe0, 0xea, 0xfa, 0xec, 0xca, + 0xf7, 0xf4, 0xf1, 0x5a, 0xe6, 0x78, 0x5a, 0x87, 0xad, 0x29, 0x38, 0x80, 0xcd,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0x3b, 0xde, + 0xef, 0xaf, 0xee, 0x78, 0x27, 0x0d, 0x6d, 0x7d, 0xff, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x42, + 0x3f, 0x03, 0x5f, 0x79, 0x10, 0x00, 0x00, } diff --git a/protocols/grpc/agent.proto b/protocols/grpc/agent.proto index 0bf40341dd..911680a050 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 5289c8d3a4..93b670386c 100644 --- a/reaper.go +++ b/reaper.go @@ -7,6 +7,9 @@ package main import ( + "bytes" + "errors" + "fmt" "os" "os/exec" "sync" @@ -28,6 +31,8 @@ type reaper interface { wait(exitCodeCh <-chan int, proc waitProcess) (int, error) lock() unlock() + run(c *exec.Cmd) error + combinedOutput(c *exec.Cmd) ([]byte, error) } type agentReaper struct { @@ -181,6 +186,34 @@ func (r *agentReaper) 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 *agentReaper) 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 *agentReaper) 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() }