From c857213b4ce96942c0adf0826c0db0c1c221e2d0 Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Mon, 5 Dec 2016 14:15:03 -0800 Subject: [PATCH] move work on execution service Signed-off-by: Kenfe-Mickael Laventure --- api/execution/container.pb.go | 719 +++++++++------------------ api/execution/container.proto | 65 ++- api/execution/execution.pb.go | 6 +- api/execution/execution.proto | 6 +- cmd/containerd/main.go | 31 +- container.go | 213 -------- execution/container.go | 80 +-- execution/executor.go | 23 +- execution/executors/executors.go | 8 +- execution/executors/oci/container.go | 23 - execution/executors/oci/oci.go | 209 +++++--- execution/executors/oci/process.go | 4 +- execution/process.go | 41 +- execution/statedir.go | 68 +++ services/execution/service.go | 116 +++-- 15 files changed, 596 insertions(+), 1016 deletions(-) delete mode 100644 container.go delete mode 100644 execution/executors/oci/container.go create mode 100644 execution/statedir.go diff --git a/api/execution/container.pb.go b/api/execution/container.pb.go index d04813d..8e83851 100644 --- a/api/execution/container.pb.go +++ b/api/execution/container.pb.go @@ -55,7 +55,7 @@ func (x Status) String() string { } func (Status) EnumDescriptor() ([]byte, []int) { return fileDescriptorContainer, []int{0} } -type CreateProcessRequest struct { +type StartProcessRequest struct { ContainerId string `protobuf:"bytes,1,opt,name=container_id,json=containerId,proto3" json:"container_id,omitempty"` Process *Process `protobuf:"bytes,2,opt,name=process" json:"process,omitempty"` Stdin string `protobuf:"bytes,3,opt,name=stdin,proto3" json:"stdin,omitempty"` @@ -63,17 +63,17 @@ type CreateProcessRequest struct { Stderr string `protobuf:"bytes,5,opt,name=stderr,proto3" json:"stderr,omitempty"` } -func (m *CreateProcessRequest) Reset() { *m = CreateProcessRequest{} } -func (*CreateProcessRequest) ProtoMessage() {} -func (*CreateProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{0} } +func (m *StartProcessRequest) Reset() { *m = StartProcessRequest{} } +func (*StartProcessRequest) ProtoMessage() {} +func (*StartProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{0} } -type CreateProcessResponse struct { +type StartProcessResponse struct { Process *Process `protobuf:"bytes,1,opt,name=process" json:"process,omitempty"` } -func (m *CreateProcessResponse) Reset() { *m = CreateProcessResponse{} } -func (*CreateProcessResponse) ProtoMessage() {} -func (*CreateProcessResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{1} } +func (m *StartProcessResponse) Reset() { *m = StartProcessResponse{} } +func (*StartProcessResponse) ProtoMessage() {} +func (*StartProcessResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{1} } type Container struct { ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` @@ -88,7 +88,7 @@ func (*Container) Descriptor() ([]byte, []int) { return fileDescriptorContainer, type Process struct { ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Pid uint64 `protobuf:"varint,2,opt,name=pid,proto3" json:"pid,omitempty"` + Pid int64 `protobuf:"varint,2,opt,name=pid,proto3" json:"pid,omitempty"` Args []string `protobuf:"bytes,3,rep,name=args" json:"args,omitempty"` Env []string `protobuf:"bytes,4,rep,name=env" json:"env,omitempty"` User *User `protobuf:"bytes,5,opt,name=user" json:"user,omitempty"` @@ -153,30 +153,14 @@ func (m *ResumeContainerRequest) Reset() { *m = ResumeContain func (*ResumeContainerRequest) ProtoMessage() {} func (*ResumeContainerRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{9} } -type StartProcessRequest struct { - Process *Process `protobuf:"bytes,1,opt,name=process" json:"process,omitempty"` -} - -func (m *StartProcessRequest) Reset() { *m = StartProcessRequest{} } -func (*StartProcessRequest) ProtoMessage() {} -func (*StartProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{10} } - -type StartProcessResponse struct { - Process *Process `protobuf:"bytes,1,opt,name=process" json:"process,omitempty"` -} - -func (m *StartProcessResponse) Reset() { *m = StartProcessResponse{} } -func (*StartProcessResponse) ProtoMessage() {} -func (*StartProcessResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{11} } - type GetProcessRequest struct { Container *Container `protobuf:"bytes,1,opt,name=container" json:"container,omitempty"` - ProcessId string `protobuf:"bytes,2,opt,name=process_id,json=processId,proto3" json:"process_id,omitempty"` + Pid int64 `protobuf:"varint,2,opt,name=pid,proto3" json:"pid,omitempty"` } func (m *GetProcessRequest) Reset() { *m = GetProcessRequest{} } func (*GetProcessRequest) ProtoMessage() {} -func (*GetProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{12} } +func (*GetProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{10} } type GetProcessResponse struct { Process *Process `protobuf:"bytes,1,opt,name=process" json:"process,omitempty"` @@ -184,24 +168,26 @@ type GetProcessResponse struct { func (m *GetProcessResponse) Reset() { *m = GetProcessResponse{} } func (*GetProcessResponse) ProtoMessage() {} -func (*GetProcessResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{13} } +func (*GetProcessResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{11} } type SignalProcessRequest struct { - Process *Process `protobuf:"bytes,1,opt,name=process" json:"process,omitempty"` - Signal uint32 `protobuf:"varint,2,opt,name=signal,proto3" json:"signal,omitempty"` + Container *Container `protobuf:"bytes,1,opt,name=container" json:"container,omitempty"` + Process *Process `protobuf:"bytes,2,opt,name=process" json:"process,omitempty"` + Signal uint32 `protobuf:"varint,3,opt,name=signal,proto3" json:"signal,omitempty"` } func (m *SignalProcessRequest) Reset() { *m = SignalProcessRequest{} } func (*SignalProcessRequest) ProtoMessage() {} -func (*SignalProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{14} } +func (*SignalProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{12} } type DeleteProcessRequest struct { - Process *Process `protobuf:"bytes,1,opt,name=process" json:"process,omitempty"` + Container *Container `protobuf:"bytes,1,opt,name=container" json:"container,omitempty"` + Process *Process `protobuf:"bytes,2,opt,name=process" json:"process,omitempty"` } func (m *DeleteProcessRequest) Reset() { *m = DeleteProcessRequest{} } func (*DeleteProcessRequest) ProtoMessage() {} -func (*DeleteProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{15} } +func (*DeleteProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{13} } type ListProcessesRequest struct { Container *Container `protobuf:"bytes,1,opt,name=container" json:"container,omitempty"` @@ -209,7 +195,7 @@ type ListProcessesRequest struct { func (m *ListProcessesRequest) Reset() { *m = ListProcessesRequest{} } func (*ListProcessesRequest) ProtoMessage() {} -func (*ListProcessesRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{16} } +func (*ListProcessesRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{14} } type ListProcessesResponse struct { Processes []*Process `protobuf:"bytes,1,rep,name=processes" json:"processes,omitempty"` @@ -217,11 +203,11 @@ type ListProcessesResponse struct { func (m *ListProcessesResponse) Reset() { *m = ListProcessesResponse{} } func (*ListProcessesResponse) ProtoMessage() {} -func (*ListProcessesResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{17} } +func (*ListProcessesResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{15} } func init() { - proto.RegisterType((*CreateProcessRequest)(nil), "containerd.v1.CreateProcessRequest") - proto.RegisterType((*CreateProcessResponse)(nil), "containerd.v1.CreateProcessResponse") + proto.RegisterType((*StartProcessRequest)(nil), "containerd.v1.StartProcessRequest") + proto.RegisterType((*StartProcessResponse)(nil), "containerd.v1.StartProcessResponse") proto.RegisterType((*Container)(nil), "containerd.v1.Container") proto.RegisterType((*Process)(nil), "containerd.v1.Process") proto.RegisterType((*User)(nil), "containerd.v1.User") @@ -230,8 +216,6 @@ func init() { proto.RegisterType((*UpdateContainerRequest)(nil), "containerd.v1.UpdateContainerRequest") proto.RegisterType((*PauseContainerRequest)(nil), "containerd.v1.PauseContainerRequest") proto.RegisterType((*ResumeContainerRequest)(nil), "containerd.v1.ResumeContainerRequest") - proto.RegisterType((*StartProcessRequest)(nil), "containerd.v1.StartProcessRequest") - proto.RegisterType((*StartProcessResponse)(nil), "containerd.v1.StartProcessResponse") proto.RegisterType((*GetProcessRequest)(nil), "containerd.v1.GetProcessRequest") proto.RegisterType((*GetProcessResponse)(nil), "containerd.v1.GetProcessResponse") proto.RegisterType((*SignalProcessRequest)(nil), "containerd.v1.SignalProcessRequest") @@ -240,12 +224,12 @@ func init() { proto.RegisterType((*ListProcessesResponse)(nil), "containerd.v1.ListProcessesResponse") proto.RegisterEnum("containerd.v1.Status", Status_name, Status_value) } -func (this *CreateProcessRequest) GoString() string { +func (this *StartProcessRequest) GoString() string { if this == nil { return "nil" } s := make([]string, 0, 9) - s = append(s, "&execution.CreateProcessRequest{") + s = append(s, "&execution.StartProcessRequest{") s = append(s, "ContainerId: "+fmt.Sprintf("%#v", this.ContainerId)+",\n") if this.Process != nil { s = append(s, "Process: "+fmt.Sprintf("%#v", this.Process)+",\n") @@ -256,12 +240,12 @@ func (this *CreateProcessRequest) GoString() string { s = append(s, "}") return strings.Join(s, "") } -func (this *CreateProcessResponse) GoString() string { +func (this *StartProcessResponse) GoString() string { if this == nil { return "nil" } s := make([]string, 0, 5) - s = append(s, "&execution.CreateProcessResponse{") + s = append(s, "&execution.StartProcessResponse{") if this.Process != nil { s = append(s, "Process: "+fmt.Sprintf("%#v", this.Process)+",\n") } @@ -370,30 +354,6 @@ func (this *ResumeContainerRequest) GoString() string { s = append(s, "}") return strings.Join(s, "") } -func (this *StartProcessRequest) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 5) - s = append(s, "&execution.StartProcessRequest{") - if this.Process != nil { - s = append(s, "Process: "+fmt.Sprintf("%#v", this.Process)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} -func (this *StartProcessResponse) GoString() string { - if this == nil { - return "nil" - } - s := make([]string, 0, 5) - s = append(s, "&execution.StartProcessResponse{") - if this.Process != nil { - s = append(s, "Process: "+fmt.Sprintf("%#v", this.Process)+",\n") - } - s = append(s, "}") - return strings.Join(s, "") -} func (this *GetProcessRequest) GoString() string { if this == nil { return "nil" @@ -403,7 +363,7 @@ func (this *GetProcessRequest) GoString() string { if this.Container != nil { s = append(s, "Container: "+fmt.Sprintf("%#v", this.Container)+",\n") } - s = append(s, "ProcessId: "+fmt.Sprintf("%#v", this.ProcessId)+",\n") + s = append(s, "Pid: "+fmt.Sprintf("%#v", this.Pid)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -423,8 +383,11 @@ func (this *SignalProcessRequest) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 6) + s := make([]string, 0, 7) s = append(s, "&execution.SignalProcessRequest{") + if this.Container != nil { + s = append(s, "Container: "+fmt.Sprintf("%#v", this.Container)+",\n") + } if this.Process != nil { s = append(s, "Process: "+fmt.Sprintf("%#v", this.Process)+",\n") } @@ -436,8 +399,11 @@ func (this *DeleteProcessRequest) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 5) + s := make([]string, 0, 6) s = append(s, "&execution.DeleteProcessRequest{") + if this.Container != nil { + s = append(s, "Container: "+fmt.Sprintf("%#v", this.Container)+",\n") + } if this.Process != nil { s = append(s, "Process: "+fmt.Sprintf("%#v", this.Process)+",\n") } @@ -510,9 +476,8 @@ type ContainerServiceClient interface { Update(ctx context.Context, in *UpdateContainerRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) Pause(ctx context.Context, in *PauseContainerRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) Resume(ctx context.Context, in *ResumeContainerRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) - CreateProcess(ctx context.Context, in *CreateProcessRequest, opts ...grpc.CallOption) (*CreateProcessResponse, error) - GetProcess(ctx context.Context, in *GetProcessRequest, opts ...grpc.CallOption) (*GetProcessResponse, error) StartProcess(ctx context.Context, in *StartProcessRequest, opts ...grpc.CallOption) (*StartProcessResponse, error) + GetProcess(ctx context.Context, in *GetProcessRequest, opts ...grpc.CallOption) (*GetProcessResponse, error) SignalProcess(ctx context.Context, in *SignalProcessRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) DeleteProcess(ctx context.Context, in *DeleteProcessRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) ListProcesses(ctx context.Context, in *ListProcessesRequest, opts ...grpc.CallOption) (*ListProcessesResponse, error) @@ -562,9 +527,9 @@ func (c *containerServiceClient) Resume(ctx context.Context, in *ResumeContainer return out, nil } -func (c *containerServiceClient) CreateProcess(ctx context.Context, in *CreateProcessRequest, opts ...grpc.CallOption) (*CreateProcessResponse, error) { - out := new(CreateProcessResponse) - err := grpc.Invoke(ctx, "/containerd.v1.ContainerService/CreateProcess", in, out, c.cc, opts...) +func (c *containerServiceClient) StartProcess(ctx context.Context, in *StartProcessRequest, opts ...grpc.CallOption) (*StartProcessResponse, error) { + out := new(StartProcessResponse) + err := grpc.Invoke(ctx, "/containerd.v1.ContainerService/StartProcess", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -580,15 +545,6 @@ func (c *containerServiceClient) GetProcess(ctx context.Context, in *GetProcessR return out, nil } -func (c *containerServiceClient) StartProcess(ctx context.Context, in *StartProcessRequest, opts ...grpc.CallOption) (*StartProcessResponse, error) { - out := new(StartProcessResponse) - err := grpc.Invoke(ctx, "/containerd.v1.ContainerService/StartProcess", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *containerServiceClient) SignalProcess(ctx context.Context, in *SignalProcessRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) { out := new(google_protobuf.Empty) err := grpc.Invoke(ctx, "/containerd.v1.ContainerService/SignalProcess", in, out, c.cc, opts...) @@ -623,9 +579,8 @@ type ContainerServiceServer interface { Update(context.Context, *UpdateContainerRequest) (*google_protobuf.Empty, error) Pause(context.Context, *PauseContainerRequest) (*google_protobuf.Empty, error) Resume(context.Context, *ResumeContainerRequest) (*google_protobuf.Empty, error) - CreateProcess(context.Context, *CreateProcessRequest) (*CreateProcessResponse, error) - GetProcess(context.Context, *GetProcessRequest) (*GetProcessResponse, error) StartProcess(context.Context, *StartProcessRequest) (*StartProcessResponse, error) + GetProcess(context.Context, *GetProcessRequest) (*GetProcessResponse, error) SignalProcess(context.Context, *SignalProcessRequest) (*google_protobuf.Empty, error) DeleteProcess(context.Context, *DeleteProcessRequest) (*google_protobuf.Empty, error) ListProcesses(context.Context, *ListProcessesRequest) (*ListProcessesResponse, error) @@ -707,20 +662,20 @@ func _ContainerService_Resume_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } -func _ContainerService_CreateProcess_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(CreateProcessRequest) +func _ContainerService_StartProcess_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StartProcessRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(ContainerServiceServer).CreateProcess(ctx, in) + return srv.(ContainerServiceServer).StartProcess(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/containerd.v1.ContainerService/CreateProcess", + FullMethod: "/containerd.v1.ContainerService/StartProcess", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ContainerServiceServer).CreateProcess(ctx, req.(*CreateProcessRequest)) + return srv.(ContainerServiceServer).StartProcess(ctx, req.(*StartProcessRequest)) } return interceptor(ctx, in, info, handler) } @@ -743,24 +698,6 @@ func _ContainerService_GetProcess_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } -func _ContainerService_StartProcess_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(StartProcessRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ContainerServiceServer).StartProcess(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/containerd.v1.ContainerService/StartProcess", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ContainerServiceServer).StartProcess(ctx, req.(*StartProcessRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _ContainerService_SignalProcess_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(SignalProcessRequest) if err := dec(in); err != nil { @@ -836,17 +773,13 @@ var _ContainerService_serviceDesc = grpc.ServiceDesc{ Handler: _ContainerService_Resume_Handler, }, { - MethodName: "CreateProcess", - Handler: _ContainerService_CreateProcess_Handler, + MethodName: "StartProcess", + Handler: _ContainerService_StartProcess_Handler, }, { MethodName: "GetProcess", Handler: _ContainerService_GetProcess_Handler, }, - { - MethodName: "StartProcess", - Handler: _ContainerService_StartProcess_Handler, - }, { MethodName: "SignalProcess", Handler: _ContainerService_SignalProcess_Handler, @@ -864,7 +797,7 @@ var _ContainerService_serviceDesc = grpc.ServiceDesc{ Metadata: "container.proto", } -func (m *CreateProcessRequest) Marshal() (dAtA []byte, err error) { +func (m *StartProcessRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -874,7 +807,7 @@ func (m *CreateProcessRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *CreateProcessRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *StartProcessRequest) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -916,7 +849,7 @@ func (m *CreateProcessRequest) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *CreateProcessResponse) Marshal() (dAtA []byte, err error) { +func (m *StartProcessResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -926,7 +859,7 @@ func (m *CreateProcessResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *CreateProcessResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *StartProcessResponse) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -1263,62 +1196,6 @@ func (m *ResumeContainerRequest) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *StartProcessRequest) 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 *StartProcessRequest) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Process != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintContainer(dAtA, i, uint64(m.Process.Size())) - n9, err := m.Process.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n9 - } - return i, nil -} - -func (m *StartProcessResponse) 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 *StartProcessResponse) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - if m.Process != nil { - dAtA[i] = 0xa - i++ - i = encodeVarintContainer(dAtA, i, uint64(m.Process.Size())) - n10, err := m.Process.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n10 - } - return i, nil -} - func (m *GetProcessRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1338,17 +1215,16 @@ func (m *GetProcessRequest) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintContainer(dAtA, i, uint64(m.Container.Size())) - n11, err := m.Container.MarshalTo(dAtA[i:]) + n9, err := m.Container.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n11 + i += n9 } - if len(m.ProcessId) > 0 { - dAtA[i] = 0x12 + if m.Pid != 0 { + dAtA[i] = 0x10 i++ - i = encodeVarintContainer(dAtA, i, uint64(len(m.ProcessId))) - i += copy(dAtA[i:], m.ProcessId) + i = encodeVarintContainer(dAtA, i, uint64(m.Pid)) } return i, nil } @@ -1372,11 +1248,11 @@ func (m *GetProcessResponse) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintContainer(dAtA, i, uint64(m.Process.Size())) - n12, err := m.Process.MarshalTo(dAtA[i:]) + n10, err := m.Process.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n12 + i += n10 } return i, nil } @@ -1396,18 +1272,28 @@ func (m *SignalProcessRequest) MarshalTo(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Process != nil { + if m.Container != nil { dAtA[i] = 0xa i++ - i = encodeVarintContainer(dAtA, i, uint64(m.Process.Size())) - n13, err := m.Process.MarshalTo(dAtA[i:]) + i = encodeVarintContainer(dAtA, i, uint64(m.Container.Size())) + n11, err := m.Container.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n13 + i += n11 + } + if m.Process != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintContainer(dAtA, i, uint64(m.Process.Size())) + n12, err := m.Process.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n12 } if m.Signal != 0 { - dAtA[i] = 0x10 + dAtA[i] = 0x18 i++ i = encodeVarintContainer(dAtA, i, uint64(m.Signal)) } @@ -1429,9 +1315,19 @@ func (m *DeleteProcessRequest) MarshalTo(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.Process != nil { + if m.Container != nil { dAtA[i] = 0xa i++ + i = encodeVarintContainer(dAtA, i, uint64(m.Container.Size())) + n13, err := m.Container.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n13 + } + if m.Process != nil { + dAtA[i] = 0x12 + i++ i = encodeVarintContainer(dAtA, i, uint64(m.Process.Size())) n14, err := m.Process.MarshalTo(dAtA[i:]) if err != nil { @@ -1527,7 +1423,7 @@ func encodeVarintContainer(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return offset + 1 } -func (m *CreateProcessRequest) Size() (n int) { +func (m *StartProcessRequest) Size() (n int) { var l int _ = l l = len(m.ContainerId) @@ -1553,7 +1449,7 @@ func (m *CreateProcessRequest) Size() (n int) { return n } -func (m *CreateProcessResponse) Size() (n int) { +func (m *StartProcessResponse) Size() (n int) { var l int _ = l if m.Process != nil { @@ -1699,26 +1595,6 @@ func (m *ResumeContainerRequest) Size() (n int) { return n } -func (m *StartProcessRequest) Size() (n int) { - var l int - _ = l - if m.Process != nil { - l = m.Process.Size() - n += 1 + l + sovContainer(uint64(l)) - } - return n -} - -func (m *StartProcessResponse) Size() (n int) { - var l int - _ = l - if m.Process != nil { - l = m.Process.Size() - n += 1 + l + sovContainer(uint64(l)) - } - return n -} - func (m *GetProcessRequest) Size() (n int) { var l int _ = l @@ -1726,9 +1602,8 @@ func (m *GetProcessRequest) Size() (n int) { l = m.Container.Size() n += 1 + l + sovContainer(uint64(l)) } - l = len(m.ProcessId) - if l > 0 { - n += 1 + l + sovContainer(uint64(l)) + if m.Pid != 0 { + n += 1 + sovContainer(uint64(m.Pid)) } return n } @@ -1746,6 +1621,10 @@ func (m *GetProcessResponse) Size() (n int) { func (m *SignalProcessRequest) Size() (n int) { var l int _ = l + if m.Container != nil { + l = m.Container.Size() + n += 1 + l + sovContainer(uint64(l)) + } if m.Process != nil { l = m.Process.Size() n += 1 + l + sovContainer(uint64(l)) @@ -1759,6 +1638,10 @@ func (m *SignalProcessRequest) Size() (n int) { func (m *DeleteProcessRequest) Size() (n int) { var l int _ = l + if m.Container != nil { + l = m.Container.Size() + n += 1 + l + sovContainer(uint64(l)) + } if m.Process != nil { l = m.Process.Size() n += 1 + l + sovContainer(uint64(l)) @@ -1801,11 +1684,11 @@ func sovContainer(x uint64) (n int) { func sozContainer(x uint64) (n int) { return sovContainer(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (this *CreateProcessRequest) String() string { +func (this *StartProcessRequest) String() string { if this == nil { return "nil" } - s := strings.Join([]string{`&CreateProcessRequest{`, + s := strings.Join([]string{`&StartProcessRequest{`, `ContainerId:` + fmt.Sprintf("%v", this.ContainerId) + `,`, `Process:` + strings.Replace(fmt.Sprintf("%v", this.Process), "Process", "Process", 1) + `,`, `Stdin:` + fmt.Sprintf("%v", this.Stdin) + `,`, @@ -1815,11 +1698,11 @@ func (this *CreateProcessRequest) String() string { }, "") return s } -func (this *CreateProcessResponse) String() string { +func (this *StartProcessResponse) String() string { if this == nil { return "nil" } - s := strings.Join([]string{`&CreateProcessResponse{`, + s := strings.Join([]string{`&StartProcessResponse{`, `Process:` + strings.Replace(fmt.Sprintf("%v", this.Process), "Process", "Process", 1) + `,`, `}`, }, "") @@ -1919,33 +1802,13 @@ func (this *ResumeContainerRequest) String() string { }, "") return s } -func (this *StartProcessRequest) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&StartProcessRequest{`, - `Process:` + strings.Replace(fmt.Sprintf("%v", this.Process), "Process", "Process", 1) + `,`, - `}`, - }, "") - return s -} -func (this *StartProcessResponse) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&StartProcessResponse{`, - `Process:` + strings.Replace(fmt.Sprintf("%v", this.Process), "Process", "Process", 1) + `,`, - `}`, - }, "") - return s -} func (this *GetProcessRequest) String() string { if this == nil { return "nil" } s := strings.Join([]string{`&GetProcessRequest{`, `Container:` + strings.Replace(fmt.Sprintf("%v", this.Container), "Container", "Container", 1) + `,`, - `ProcessId:` + fmt.Sprintf("%v", this.ProcessId) + `,`, + `Pid:` + fmt.Sprintf("%v", this.Pid) + `,`, `}`, }, "") return s @@ -1965,6 +1828,7 @@ func (this *SignalProcessRequest) String() string { return "nil" } s := strings.Join([]string{`&SignalProcessRequest{`, + `Container:` + strings.Replace(fmt.Sprintf("%v", this.Container), "Container", "Container", 1) + `,`, `Process:` + strings.Replace(fmt.Sprintf("%v", this.Process), "Process", "Process", 1) + `,`, `Signal:` + fmt.Sprintf("%v", this.Signal) + `,`, `}`, @@ -1976,6 +1840,7 @@ func (this *DeleteProcessRequest) String() string { return "nil" } s := strings.Join([]string{`&DeleteProcessRequest{`, + `Container:` + strings.Replace(fmt.Sprintf("%v", this.Container), "Container", "Container", 1) + `,`, `Process:` + strings.Replace(fmt.Sprintf("%v", this.Process), "Process", "Process", 1) + `,`, `}`, }, "") @@ -2009,7 +1874,7 @@ func valueToStringContainer(v interface{}) string { pv := reflect.Indirect(rv).Interface() return fmt.Sprintf("*%v", pv) } -func (m *CreateProcessRequest) Unmarshal(dAtA []byte) error { +func (m *StartProcessRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2032,10 +1897,10 @@ func (m *CreateProcessRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: CreateProcessRequest: wiretype end group for non-group") + return fmt.Errorf("proto: StartProcessRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: CreateProcessRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: StartProcessRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2208,7 +2073,7 @@ func (m *CreateProcessRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *CreateProcessResponse) Unmarshal(dAtA []byte) error { +func (m *StartProcessResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2231,10 +2096,10 @@ func (m *CreateProcessResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: CreateProcessResponse: wiretype end group for non-group") + return fmt.Errorf("proto: StartProcessResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: CreateProcessResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: StartProcessResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2523,7 +2388,7 @@ func (m *Process) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Pid |= (uint64(b) & 0x7F) << shift + m.Pid |= (int64(b) & 0x7F) << shift if b < 0x80 { break } @@ -3309,172 +3174,6 @@ func (m *ResumeContainerRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *StartProcessRequest) 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 ErrIntOverflowContainer - } - 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: StartProcessRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StartProcessRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Process", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowContainer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthContainer - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Process == nil { - m.Process = &Process{} - } - if err := m.Process.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipContainer(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthContainer - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *StartProcessResponse) 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 ErrIntOverflowContainer - } - 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: StartProcessResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StartProcessResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Process", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowContainer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthContainer - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Process == nil { - m.Process = &Process{} - } - if err := m.Process.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipContainer(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthContainer - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *GetProcessRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -3538,10 +3237,10 @@ func (m *GetProcessRequest) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProcessId", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Pid", wireType) } - var stringLen uint64 + m.Pid = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowContainer @@ -3551,21 +3250,11 @@ func (m *GetProcessRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + m.Pid |= (int64(b) & 0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthContainer - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProcessId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipContainer(dAtA[iNdEx:]) @@ -3700,6 +3389,39 @@ func (m *SignalProcessRequest) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Container", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContainer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthContainer + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Container == nil { + m.Container = &Container{} + } + if err := m.Container.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Process", wireType) } @@ -3732,7 +3454,7 @@ func (m *SignalProcessRequest) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Signal", wireType) } @@ -3802,6 +3524,39 @@ func (m *DeleteProcessRequest) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Container", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContainer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthContainer + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Container == nil { + m.Container = &Container{} + } + if err := m.Container.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Process", wireType) } @@ -4127,60 +3882,58 @@ var ( func init() { proto.RegisterFile("container.proto", fileDescriptorContainer) } var fileDescriptorContainer = []byte{ - // 873 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xa4, 0x56, 0x41, 0x93, 0xe2, 0x44, - 0x14, 0x9e, 0x00, 0x13, 0x26, 0x8f, 0xcd, 0x8a, 0x3d, 0x40, 0xa5, 0x50, 0x59, 0x36, 0xae, 0x4a, - 0x59, 0xb5, 0xb0, 0xa2, 0xe5, 0xc5, 0xd3, 0xee, 0x80, 0x91, 0xaa, 0x11, 0xb1, 0x59, 0xca, 0x2a, - 0x2f, 0x98, 0x21, 0x2d, 0x1b, 0x8b, 0x49, 0xd8, 0xa4, 0x33, 0xea, 0x6d, 0xff, 0x8c, 0x3f, 0xc0, - 0xb3, 0x7f, 0x60, 0x8f, 0x1e, 0x3d, 0x59, 0x0e, 0xbf, 0xc0, 0x9f, 0x60, 0x75, 0xa7, 0x13, 0x20, - 0x09, 0xc8, 0x32, 0xb7, 0xd7, 0x8f, 0xd7, 0x5f, 0xbe, 0xf7, 0x75, 0x7f, 0xaf, 0x81, 0xb7, 0x66, - 0xae, 0x43, 0x4d, 0xdb, 0x21, 0x5e, 0x7b, 0xe9, 0xb9, 0xd4, 0x45, 0x6a, 0x9c, 0xb0, 0xda, 0x37, - 0x9f, 0xd4,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d, 0x6a, 0x48, 0x7f, - 0xae, 0x1a, 0xd2, 0x3f, 0xab, 0x86, 0x74, 0x25, 0x73, 0x26, 0x9f, 0xfe, 0x17, 0x00, 0x00, 0xff, - 0xff, 0x9f, 0x3d, 0x76, 0x6b, 0xd9, 0x0a, 0x00, 0x00, + // 841 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xc4, 0x56, 0xcd, 0x6e, 0xeb, 0x44, + 0x14, 0xee, 0xc4, 0x89, 0xd3, 0x9c, 0x5c, 0x5f, 0xc2, 0x34, 0x8d, 0xac, 0x80, 0x72, 0x73, 0xcd, + 0x05, 0x22, 0xa4, 0x9b, 0x5c, 0x02, 0x62, 0xc3, 0xaa, 0x6d, 0x42, 0xa8, 0x54, 0x42, 0x98, 0x34, + 0x42, 0x42, 0x42, 0x95, 0x1b, 0x0f, 0xa9, 0xa5, 0xd4, 0x76, 0xed, 0x71, 0x81, 0x5d, 0x1f, 0x83, + 0x17, 0x60, 0xcf, 0x63, 0x74, 0xc9, 0x92, 0x15, 0xd0, 0x3c, 0x01, 0x8f, 0x80, 0x66, 0xfc, 0x93, + 0xc4, 0x76, 0x42, 0x28, 0x48, 0x77, 0x77, 0xe6, 0xe4, 0xcc, 0xe7, 0xef, 0x3b, 0x3d, 0xdf, 0x99, + 0xc2, 0x1b, 0x53, 0xdb, 0x62, 0xba, 0x69, 0x51, 0xb7, 0xed, 0xb8, 0x36, 0xb3, 0xb1, 0x12, 0x27, + 0x8c, 0xf6, 0xed, 0x87, 0xf5, 0xb7, 0x66, 0xb6, 0x3d, 0x9b, 0xd3, 0x8e, 0xf8, 0xf1, 0xd2, 0xff, + 0xae, 0x43, 0xaf, 0x1d, 0xf6, 0x63, 0x50, 0x5b, 0xaf, 0xce, 0xec, 0x99, 0x2d, 0xc2, 0x0e, 0x8f, + 0x82, 0xac, 0xf6, 0x0b, 0x82, 0x83, 0x31, 0xd3, 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xf9, 0xdb, 0x8d, 0xfb, 0x50, 0x10, + 0x8e, 0xc5, 0x2f, 0x92, 0x6d, 0xc9, 0xf2, 0xf1, 0x46, 0x98, 0x01, 0xc8, 0x81, 0x8f, 0x53, 0x7c, + 0xb2, 0xed, 0xbd, 0x11, 0xe8, 0x6b, 0x78, 0xb2, 0xfa, 0xf8, 0xa6, 0x3a, 0x96, 0xf1, 0xbf, 0x44, + 0xaa, 0x63, 0x99, 0xaf, 0xf7, 0x57, 0x00, 0x4b, 0x63, 0xe3, 0x66, 0xba, 0xc9, 0x09, 0xd0, 0xe7, + 0x5b, 0x2a, 0x42, 0xc8, 0x33, 0x50, 0xd6, 0x2c, 0x8e, 0x53, 0x44, 0x32, 0x16, 0xc0, 0x46, 0xe5, + 0x67, 0xa0, 0xac, 0xb9, 0x32, 0x85, 0x96, 0xe5, 0xd9, 0x8d, 0x68, 0xdf, 0x80, 0xb2, 0xe6, 0x88, + 0x14, 0x5a, 0x96, 0xff, 0xea, 0x2f, 0xb6, 0x17, 0x05, 0xba, 0x8f, 0xdf, 0xbe, 0x7f, 0x68, 0xec, + 0xfd, 0xf6, 0xd0, 0xd8, 0xfb, 0xeb, 0xa1, 0x81, 0xee, 0x16, 0x0d, 0x74, 0xbf, 0x68, 0xa0, 0x5f, + 0x17, 0x0d, 0xf4, 0xe7, 0xa2, 0x81, 0x2e, 0x65, 0xc1, 0xe4, 0xa3, 0xbf, 0x03, 0x00, 0x00, 0xff, + 0xff, 0x93, 0x32, 0xdb, 0x86, 0x4d, 0x0a, 0x00, 0x00, } diff --git a/api/execution/container.proto b/api/execution/container.proto index c726faa..b3e9811 100644 --- a/api/execution/container.proto +++ b/api/execution/container.proto @@ -11,50 +11,49 @@ service ContainerService { rpc Pause(PauseContainerRequest) returns (google.protobuf.Empty); rpc Resume(ResumeContainerRequest) returns (google.protobuf.Empty); - rpc CreateProcess(CreateProcessRequest) returns (CreateProcessResponse); - rpc GetProcess(GetProcessRequest) returns (GetProcessResponse); rpc StartProcess(StartProcessRequest) returns (StartProcessResponse); + rpc GetProcess(GetProcessRequest) returns (GetProcessResponse); rpc SignalProcess(SignalProcessRequest) returns (google.protobuf.Empty); rpc DeleteProcess(DeleteProcessRequest) returns (google.protobuf.Empty); rpc ListProcesses(ListProcessesRequest) returns (ListProcessesResponse); } -message CreateProcessRequest { - string container_id = 1; - Process process = 2; - string stdin = 3; +message StartProcessRequest { + string container_id = 1; + Process process = 2; + string stdin = 3; string stdout = 4; string stderr = 5; } -message CreateProcessResponse { - Process process = 1; +message StartProcessResponse { + Process process = 1; } message Container { string id = 1 [(gogoproto.customname) = "ID"]; - string bundle_path = 2; - Process process = 3; - Status status = 4; + string bundle_path = 2; + Process process = 3; + Status status = 4; } message Process { string id = 1 [(gogoproto.customname) = "ID"]; - uint64 pid = 2; + int64 pid = 2; repeated string args = 3; repeated string env = 4; User user = 5; string cwd = 6; bool terminal = 7; - Status status = 8; - uint32 exit_status = 9; + Status status = 8; + uint32 exit_status = 9; } enum Status { - CREATED = 0; - RUNNING = 1; - STOPPED = 2; - PAUSED = 3; + CREATED = 0; + RUNNING = 1; + STOPPED = 2; + PAUSED = 3; } message User { @@ -73,7 +72,7 @@ message GetContainerResponse { message UpdateContainerRequest { Container container = 1; - string bundle_path = 2; + string bundle_path = 2; } message PauseContainerRequest { @@ -84,38 +83,30 @@ message ResumeContainerRequest { string id = 1 [(gogoproto.customname) = "ID"]; } -message StartProcessRequest { - Process process = 1; -} - -message StartProcessResponse { - Process process = 1; -} - message GetProcessRequest { - Container container = 1; - string process_id = 2; + Container container = 1; + int64 pid = 2; } message GetProcessResponse { - Process process = 1; + Process process = 1; } message SignalProcessRequest { - Process process = 1; - uint32 signal = 2; + Container container = 1; + Process process = 2; + uint32 signal = 3; } message DeleteProcessRequest { - Process process = 1; + Container container = 1; + Process process = 2; } message ListProcessesRequest { - Container container = 1; + Container container = 1; } message ListProcessesResponse { - repeated Process processes = 1; + repeated Process processes = 1; } - - diff --git a/api/execution/execution.pb.go b/api/execution/execution.pb.go index 2df69ea..c0c61cf 100644 --- a/api/execution/execution.pb.go +++ b/api/execution/execution.pb.go @@ -16,8 +16,8 @@ DeleteContainerResponse ListContainersRequest ListContainersResponse - CreateProcessRequest - CreateProcessResponse + StartProcessRequest + StartProcessResponse Container Process User @@ -26,8 +26,6 @@ UpdateContainerRequest PauseContainerRequest ResumeContainerRequest - StartProcessRequest - StartProcessResponse GetProcessRequest GetProcessResponse SignalProcessRequest diff --git a/api/execution/execution.proto b/api/execution/execution.proto index d67e09e..b6df8a8 100644 --- a/api/execution/execution.proto +++ b/api/execution/execution.proto @@ -14,8 +14,8 @@ service ExecutionService{ message CreateContainerRequest { string id = 1 [(gogoproto.customname) = "ID"]; - string bundle_path = 2; - string stdin = 3; + string bundle_path = 2; + string stdin = 3; string stdout = 4; string stderr = 5; } @@ -38,5 +38,3 @@ message ListContainersRequest { message ListContainersResponse { repeated Container containers = 1; } - - diff --git a/cmd/containerd/main.go b/cmd/containerd/main.go index a19e702..e36c141 100644 --- a/cmd/containerd/main.go +++ b/cmd/containerd/main.go @@ -3,7 +3,6 @@ package main import ( "fmt" "net" - "net/http" "os" "os/signal" "path/filepath" @@ -15,7 +14,7 @@ import ( "github.com/docker/containerd" api "github.com/docker/containerd/api/execution" "github.com/docker/containerd/services/execution" - metrics "github.com/docker/go-metrics" + // metrics "github.com/docker/go-metrics" "github.com/urfave/cli" ) @@ -26,10 +25,10 @@ func main() { app.Usage = ` __ _ __ _________ ____ / /_____ _(_)___ ___ _________/ / - / ___/ __ \/ __ \/ __/ __ ` + "`" + `/ / __ \/ _ \/ ___/ __ / -/ /__/ /_/ / / / / /_/ /_/ / / / / / __/ / / /_/ / -\___/\____/_/ /_/\__/\__,_/_/_/ /_/\___/_/ \__,_/ - + / ___/ __ \/ __ \/ __/ __ ` + "`" + `/ / __ \/ _ \/ ___/ __ / +/ /__/ /_/ / / / / /_/ /_/ / / / / / __/ / / /_/ / +\___/\____/_/ /_/\__/\__,_/_/_/ /_/\___/_/ \__,_/ + high performance container runtime ` app.Flags = []cli.Flag{ @@ -68,9 +67,9 @@ high performance container runtime signals := make(chan os.Signal, 2048) signal.Notify(signals, syscall.SIGTERM, syscall.SIGINT) - if address := context.GlobalString("metrics-address"); address != "" { - go serveMetrics(address) - } + // if address := context.GlobalString("metrics-address"); address != "" { + // go serveMetrics(address) + // } path := context.GlobalString("socket") if path == "" { @@ -120,13 +119,13 @@ func createUnixSocket(path string) (net.Listener, error) { return net.Listen("unix", path) } -func serveMetrics(address string) { - m := http.NewServeMux() - m.Handle("/metrics", metrics.Handler()) - if err := http.ListenAndServe(address, m); err != nil { - logrus.WithError(err).Fatal("containerd: metrics server failure") - } -} +// func serveMetrics(address string) { +// m := http.NewServeMux() +// m.Handle("/metrics", metrics.Handler()) +// if err := http.ListenAndServe(address, m); err != nil { +// logrus.WithError(err).Fatal("containerd: metrics server failure") +// } +// } func serveGRPC(server *grpc.Server, l net.Listener) { defer l.Close() diff --git a/container.go b/container.go deleted file mode 100644 index dd57984..0000000 --- a/container.go +++ /dev/null @@ -1,213 +0,0 @@ -package containerd - -import ( - "encoding/json" - "io" - "os" - "path/filepath" - "sync" - - specs "github.com/opencontainers/runtime-spec/specs-go" -) - -type ContainerConfig interface { - ID() string - Root() string // bundle path - Spec() (*specs.Spec, error) - Runtime() (Runtime, error) -} - -func NewContainer(config ContainerConfig) (*Container, error) { - var ( - id = config.ID() - root = config.Root() - path = filepath.Join(root, id) - ) - s, err := config.Spec() - if err != nil { - return nil, err - } - // HACK: for runc to allow to use this path without a premounted rootfs - if err := os.MkdirAll(filepath.Join(path, s.Root.Path), 0711); err != nil { - return nil, err - } - f, err := os.Create(filepath.Join(path, "config.json")) - if err != nil { - return nil, err - } - // write the spec file to the container's directory - err = json.NewEncoder(f).Encode(s) - f.Close() - if err != nil { - return nil, err - } - r, err := config.Runtime() - if err != nil { - return nil, err - } - return &Container{ - id: id, - path: path, - s: s, - driver: r, - }, nil -} - -func LoadContainer(config ContainerConfig) (*Container, error) { - var ( - id = config.ID() - root = config.Root() - path = filepath.Join(root, id) - ) - spec, err := loadSpec(path) - if err != nil { - return nil, err - } - r, err := config.Runtime() - if err != nil { - return nil, err - } - process, err := r.Load(id) - if err != nil { - return nil, err - } - // TODO: load exec processes - return &Container{ - id: id, - path: path, - s: spec, - driver: r, - init: &Process{ - d: process, - driver: r, - }, - }, nil -} - -func loadSpec(path string) (*specs.Spec, error) { - f, err := os.Open(filepath.Join(path, "config.json")) - if err != nil { - return nil, err - } - var s specs.Spec - err = json.NewDecoder(f).Decode(&s) - f.Close() - if err != nil { - return nil, err - } - return &s, nil -} - -type Container struct { - mu sync.Mutex - id string - path string - s *specs.Spec - - driver Runtime - - Stdin io.Reader - Stdout io.Writer - Stderr io.Writer - - // init is the container's init processes - init *Process - // processes is a list of additional processes executed inside the container - // via the NewProcess method on the container - processes []*Process -} - -// ID returns the id of the container -func (c *Container) ID() string { - return c.id -} - -// Path returns the fully qualified path to the container on disk -func (c *Container) Path() string { - return c.path -} - -// Spec returns the OCI runtime spec for the container -func (c *Container) Spec() *specs.Spec { - return c.s -} - -// Create will create the container on the system by running the runtime's -// initial setup and process waiting for the user process to be started -func (c *Container) Create() error { - c.mu.Lock() - defer c.mu.Unlock() - d, err := c.driver.Create(c) - if err != nil { - return err - } - c.init = &Process{ - d: d, - driver: c.driver, - Stdin: c.Stdin, - Stdout: c.Stdout, - Stderr: c.Stderr, - } - return nil -} - -// Start will start the container's user specified process -func (c *Container) Start() error { - c.mu.Lock() - defer c.mu.Unlock() - return c.driver.Start(c) -} - -// NewProcess will create a new process that will be executed inside the -// container and tied to the init processes lifecycle -func (c *Container) NewProcess(spec *specs.Process) (*Process, error) { - c.mu.Lock() - defer c.mu.Unlock() - process := &Process{ - s: spec, - c: c, - exec: true, - driver: c.driver, - } - c.processes = append(c.processes, process) - return process, nil -} - -// Pid returns the pid of the init or main process hosted inside the container -func (c *Container) Pid() int { - c.mu.Lock() - if c.init == nil { - c.mu.Unlock() - return -1 - } - pid := c.init.Pid() - c.mu.Unlock() - return pid -} - -// Wait will perform a blocking wait on the init process of the container -func (c *Container) Wait() (uint32, error) { - c.mu.Lock() - proc := c.init - c.mu.Unlock() - return proc.Wait() -} - -// Signal will send the provided signal to the init process of the container -func (c *Container) Signal(s os.Signal) error { - c.mu.Lock() - defer c.mu.Unlock() - return c.init.Signal(s) -} - -// Delete will delete the container if it no long has any processes running -// inside the container and removes all state on disk for the container -func (c *Container) Delete() error { - c.mu.Lock() - defer c.mu.Unlock() - err := c.driver.Delete(c) - if rerr := os.RemoveAll(c.path); err == nil { - err = rerr - } - return err -} diff --git a/execution/container.go b/execution/container.go index 1d35405..e52b975 100644 --- a/execution/container.go +++ b/execution/container.go @@ -1,85 +1,29 @@ package execution -import ( - "fmt" - "os" - "path/filepath" - - specs "github.com/opencontainers/runtime-spec/specs-go" -) - -type ContainerController interface { - Pause(*Container) error - Resume(*Container) error - Status(*Container) (Status, error) - Process(c *Container, pid int) (*Process, error) - Processes(*Container) ([]*Process, error) -} - -func NewContainer(c ContainerController) *Container { - return &Container{ - controller: c, - } -} - type Container struct { - ID string - Bundle string - Root string - controller ContainerController + ID string + Bundle string + StateDir StateDir - processes map[int]*Process + processes map[string]Process } -func (c *Container) Process(pid int) (*Process, error) { - for _, p := range c.processes { - if p.Pid == pid { - return p, nil - } - } - return nil, fmt.Errorf("todo make real error") +func (c *Container) AddProcess(p Process) { + c.processes[p.ID()] = p } -func (c *Container) CreateProcess(spec *specs.Process) (*Process, error) { - if err := os.MkdirAll(filepath.Join(c.Root, c.getNextProcessID()), 0660); err != nil { - return nil, err - } - process := &Process{ - Spec: spec, - controller: c.controller, - } - c.processes = append(c.processes, process) - return process, nil +func (c *Container) GetProcess(id string) Process { + return c.processes[id] } -func (c *Container) DeleteProcess(pid int) error { - process, ok := c.processes[pid] - if !ok { - return fmt.Errorf("it no here") - } - if process.Status() != Stopped { - return fmt.Errorf("tototoit not stopped ok?") - } - delete(c.processes, pid) - return os.RemoveAll(p.Root) +func (c *Container) RemoveProcess(id string) { + delete(c.processes, id) } -func (c *Container) Processes() []*Process { - var out []*Process +func (c *Container) Processes() []Process { + var out []Process for _, p := range c.processes { out = append(out, p) } return out } - -func (c *Container) Pause() error { - return c.controller.Pause(c) -} - -func (c *Container) Resume() error { - return c.controller.Resume(c) -} - -func (c *Container) Status() (Status, error) { - return c.controller.Status(c) -} diff --git a/execution/executor.go b/execution/executor.go index fec24ef..92e9362 100644 --- a/execution/executor.go +++ b/execution/executor.go @@ -1,6 +1,11 @@ package execution -import "io" +import ( + "io" + "os" + + "github.com/opencontainers/runtime-spec/specs-go" +) type CreateOpts struct { Bundle string @@ -9,9 +14,23 @@ type CreateOpts struct { Stderr io.Writer } +type CreateProcessOpts struct { + Spec specs.Process + Stdin io.Reader + Stdout io.Writer + Stderr io.Writer +} + type Executor interface { Create(id string, o CreateOpts) (*Container, error) + Pause(*Container) error + Resume(*Container) error + Status(*Container) (Status, error) List() ([]*Container, error) Load(id string) (*Container, error) - Delete(string) error + Delete(*Container) error + + StartProcess(*Container, CreateProcessOpts) (Process, error) + SignalProcess(*Container, os.Signal) error + DeleteProcess(*Container, string) error } diff --git a/execution/executors/executors.go b/execution/executors/executors.go index 374ce3f..d5fa393 100644 --- a/execution/executors/executors.go +++ b/execution/executors/executors.go @@ -1,13 +1,13 @@ package executors -import "github.com/docker/containerd" +import "github.com/docker/containerd/execution" -var executors = make(map[string]func() containerd.Executor) +var executors = make(map[string]func() execution.Executor) -func Register(name string, e func() containerd.Executor) { +func Register(name string, e func() execution.Executor) { executors[name] = e } -func Get(name string) func() containerd.Executor { +func Get(name string) func() execution.Executor { return executors[name] } diff --git a/execution/executors/oci/container.go b/execution/executors/oci/container.go deleted file mode 100644 index f6965ac..0000000 --- a/execution/executors/oci/container.go +++ /dev/null @@ -1,23 +0,0 @@ -package oci - -import "github.com/docker/containerd/execution" - -type containerController struct { - root string -} - -func (c *containerController) Process(container *execution.Container, pid int) (*execution.Process, error) { - -} - -func (c *containerController) Processes(container *execution.Container) ([]*execution.Process, error) { - -} - -func (c *containerController) Pause(container *execution.Container) error { - return command(c.root, "pause", container.ID).Run() -} - -func (c *containerController) Resume(container *execution.Container) error { - return command(c.root, "resume", container.ID).Run() -} diff --git a/execution/executors/oci/oci.go b/execution/executors/oci/oci.go index a3fe37c..22e8246 100644 --- a/execution/executors/oci/oci.go +++ b/execution/executors/oci/oci.go @@ -1,16 +1,14 @@ package oci import ( - "encoding/json" "errors" "fmt" "io/ioutil" - "os/exec" + "os" "path/filepath" - "strconv" - "time" + "syscall" - "github.com/docker/containerd" + "github.com/crosbymichael/go-runc" "github.com/docker/containerd/execution" "github.com/docker/containerd/executors" ) @@ -25,107 +23,178 @@ func init() { func New(root string) *OCIRuntime { return &OCIRuntime{ root: root, + Runc: &runc.Runc{ + Root: filepath.Join(root, "runc"), + }, } } type OCIRuntime struct { // root holds runtime state information for the containers - // launched by the runtime root string + runc *runc.Runc } func (r *OCIRuntime) Create(id string, o execution.CreateOpts) (*execution.Container, error) { + var err error + + stateDir, err := NewStateDir(r.root, id) + if err != nil { + return nil, err + } + + initStateDir, err := stateDir.NewProcess() + if err != nil { + return nil, err + } + // /run/runc/redis/1/pid - pidFile := filepath.Join(r.root, id, "1", "pid") - cmd := command(r.root, "create", - "--pid-file", pidFile, - "--bundle", o.Bundle, - id, - ) - cmd.Stdin, cmd.Stdout, cmd.Stderr = o.Stdin, o.Stdout, o.Stderr - if err := cmd.Run(); err != nil { - return nil, err - } - // TODO: kill on error - data, err := ioutil.ReadFile(pidFile) + pidFile := filepath.Join(initStateDir, "pid") + err = r.runc.Create(id, o.Bundle, &runc.CreateOpts{ + Pidfile: pidfile, + Stdin: o.Stdin, + Stdout: o.Stdout, + Stderr: o.Stderr, + }) if err != nil { return nil, err } - pid, err := strconv.Atoi(string(data)) + pid, err := runc.ReadPifFile(pidfile) if err != nil { return nil, err } - container := execution.NewContainer(r) - container.ID = id - container.Root = filepath.Join(r.root, id) - container.Bundle = o.Bundle - process, err := container.CreateProcess(nil) + process, err := newProcess(pid) if err != nil { return nil, err } - process.Pid = pid - process.Stdin = o.Stdin - process.Stdout = o.Stdout - process.Stderr = o.Stderr + + container := &execution.Container{ + ID: id, + Bundle: o.Bundle, + StateDir: stateDir, + } + container.AddProcess(process) + return container, nil } -func (r *OCIRuntime) Load(id string) (containerd.ProcessDelegate, error) { - data, err := r.Command("state", id).Output() +func (r *OCIRuntime) load(runcC *runc.Container) (*execution.Container, error) { + container := &execution.Container{ + ID: runcC.ID, + Bundle: runcC.Bundle, + StateDir: StateDir(filepath.Join(r.root, runcC.ID)), + } + + process, err := newProcess(runcC.Pid) if err != nil { return nil, err } - var s state - if err := json.Unmarshal(data, &s); err != nil { + container.AddProcess(process) + + // /run/containerd/container-id/processess/process-id + dirs, err := ioutil.ReadDir(filepath.Join(container.Root)) + if err != nil { return nil, err } - return newProcess(s.Pid) + + return container, nil } -func (r *OCIRuntime) Delete(id string) error { - return command(r.root, "delete", id).Run() +func (r *OCIRuntime) List() ([]*execution.Container, error) { + runcCs, err := r.runc.List() + if err != nil { + return nil, err + } + + containers := make([]*execution.Container) + for _, c := range runcCs { + container, err := r.load(c) + if err != nil { + return nil, err + } + containers = append(containers, container) + } + + return containers, nil } -func (r *OCIRuntime) Exec(c *containerd.Container, p *containerd.Process) (containerd.ProcessDelegate, error) { - f, err := ioutil.TempFile(filepath.Join(r.root, c.ID()), "process") +func (r *OCIRuntime) Load(id string) (*execution.Container, error) { + runcC, err := r.runc.State(id) if err != nil { return nil, err } - path := f.Name() - pidFile := fmt.Sprintf("%s/%s.pid", filepath.Join(r.root, c.ID()), filepath.Base(path)) - err = json.NewEncoder(f).Encode(p.Spec()) - f.Close() - if err != nil { - return nil, err - } - cmd := r.Command("exec", "--detach", "--process", path, "--pid-file", pidFile, c.ID()) - cmd.Stdin, cmd.Stdout, cmd.Stderr = p.Stdin, p.Stdout, p.Stderr - if err := cmd.Run(); err != nil { - return nil, err - } - data, err := ioutil.ReadFile(pidFile) - if err != nil { - return nil, err - } - i, err := strconv.Atoi(string(data)) - if err != nil { - return nil, err - } - return newProcess(i) + + return r.load(runcC) } -type state struct { - ID string `json:"id"` - Pid int `json:"pid"` - Status string `json:"status"` - Bundle string `json:"bundle"` - Rootfs string `json:"rootfs"` - Created time.Time `json:"created"` - Annotations map[string]string `json:"annotations"` +func (r *OCIRuntime) Delete(c *execution.Container) error { + if err := r.runc.Delete(c.ID); err != nil { + return err + } + c.StateDir.Delete() + return nil } -func command(root, args ...string) *exec.Cmd { - return exec.Command("runc", append( - []string{"--root", root}, - args...)...) +func (r *OCIRuntime) Pause(c *execution.Container) error { + return r.runc.Pause(c.ID) +} + +func (r *OCIRuntime) Resume(c *execution.Container) error { + return r.runc.Resume(c.ID) +} + +func (r *OCIRuntime) StartProcess(c *execution.Container, o CreateProcessOpts) (execution.Process, error) { + var err error + + processStateDir, err := c.StateDir.NewProcess() + if err != nil { + return nil, err + } + defer func() { + if err != nil { + c.StateDir.DeleteProcess(filepath.Base(processStateDir)) + } + }() + + pidFile := filepath.Join(processStateDir, id) + err := r.runc.ExecProcess(c.ID, o.spec, &runc.ExecOpts{ + PidFile: pidfile, + Detach: true, + Stdin: o.stdin, + Stdout: o.stdout, + Stderr: o.stderr, + }) + if err != nil { + return nil, err + } + pid, err := runc.ReadPidFile(pidfile) + if err != nil { + return nil, err + } + + process, err := newProcess(pid) + if err != nil { + return nil, err + } + + container.AddProcess(process) + + return process, nil +} + +func (r *OCIRuntime) SignalProcess(c *execution.Container, id string, sig os.Signal) error { + process := c.GetProcess(id) + if process == nil { + return fmt.Errorf("Make a Process Not Found error") + } + return syscall.Kill(int(process.Pid()), os.Signal) +} + +func (r *OCIRuntime) GetProcess(c *execution.Container, id string) process { + return c.GetProcess(id) +} + +func (r *OCIRuntime) DeleteProcess(c *execution.Container, id string) error { + c.StateDir.DeleteProcess(id) + return nil } diff --git a/execution/executors/oci/process.go b/execution/executors/oci/process.go index c89a0a8..5f5b911 100644 --- a/execution/executors/oci/process.go +++ b/execution/executors/oci/process.go @@ -3,9 +3,11 @@ package oci import ( "os" "syscall" + + "github.com/docker/containerd/execution" ) -func newProcess(pid int) (*process, error) { +func newProcess(pid int) (execution.Process, error) { proc, err := os.FindProcess(pid) if err != nil { return nil, err diff --git a/execution/process.go b/execution/process.go index 5a19836..a0cf04e 100644 --- a/execution/process.go +++ b/execution/process.go @@ -1,41 +1,18 @@ package execution import ( - "io" "os" - specs "github.com/opencontainers/runtime-spec/specs-go" + "github.com/opencontainers/runtime-spec/specs-go" ) -type ProcessController interface { - Start(*Process) error - Status(*Process) (Status, error) - Wait(*Process) (uint32, error) - Signal(*Process, os.Signal) error -} +type Process interface { + ID() string + Pid() int64 + Spec() *specs.Process -type Process struct { - Pid int - Spec *specs.Process - Stdin io.Reader - Stdout io.Writer - Stderr io.Writer - - controller ProcessController -} - -func (p *Process) Status() (Status, error) { - return p.controller.Status(p) -} - -func (p *Process) Wait() (uint32, error) { - return p.controller.Wait(p) -} - -func (p *Process) Signal(s os.Signal) error { - return p.controller.Signal(p, s) -} - -func (p *Process) Start() error { - return p.controller.Start(p) + Start() error + Status() (Status, error) + Wait() (uint32, error) + Signal(os.Signal) error } diff --git a/execution/statedir.go b/execution/statedir.go new file mode 100644 index 0000000..fb0379b --- /dev/null +++ b/execution/statedir.go @@ -0,0 +1,68 @@ +package execution + +import ( + "io/ioutil" + "os" + "path/filepath" +) + +const processesDir = "processes" + +type StateDir string + +func NewStateDir(root, id string) (StateDir, error) { + path := filepath.Join(root, id) + err := os.Mkdir(path, 0700) + if err != nil { + return "", err + } + + err = os.Mkdir(filepath.Join(path, processesDir), 0700) + if err != nil { + os.RemoveAll(path) + return "", err + } + + return StateDir(path), err +} + +func (s StateDir) Delete() error { + return os.RemoveAll(string(s)) +} + +func (s StateDir) NewProcess(id string) (string, error) { + // TODO: generate id + newPath := filepath.Join(string(s), "1") + err := os.Mkdir(newPath, 0755) + if err != nil { + return "", err + } + + return newPath, nil +} + +func (s StateDir) ProcessDir(id string) string { + return filepath.Join(string(s), id) +} + +func (s StateDir) DeleteProcess(id string) error { + return os.RemoveAll(filepath.Join(string(s), id)) +} + +func (s StateDir) Processes() ([]string, error) { + basepath := filepath.Join(string(s), processesDir) + dirs, err := ioutil.ReadDir(basepath) + if err != nil { + return nil, err + } + + paths := make([]string, 0) + for _, d := range dirs { + + if d.IsDir() { + paths = append(paths, filepath.Join(basepath, d.Name())) + } + } + + return paths, nil +} diff --git a/services/execution/service.go b/services/execution/service.go index 5e4820a..a1502b8 100644 --- a/services/execution/service.go +++ b/services/execution/service.go @@ -1,11 +1,14 @@ package execution import ( - "context" + "fmt" api "github.com/docker/containerd/api/execution" "github.com/docker/containerd/execution" - "github.com/docker/containerd/executors" + "github.com/docker/containerd/execution/executors" + google_protobuf "github.com/golang/protobuf/ptypes/empty" + "github.com/opencontainers/runtime-spec/specs-go" + "golang.org/x/net/context" ) type Opts struct { @@ -14,7 +17,7 @@ type Opts struct { } func New(o Opts) (*Service, error) { - executor := executors.Get(o.Runtime)(o.Root) + executor := executors.Get(o.Runtime)() return &Service{ o: o, executor: executor, @@ -28,34 +31,46 @@ type Service struct { func (s *Service) Create(ctx context.Context, r *api.CreateContainerRequest) (*api.CreateContainerResponse, error) { // TODO: write io and bundle path to dir - container, err := s.executor.Create(r.ID, r.BundlePath, &IO{}) + // TODO: open IOs + container, err := s.executor.Create(r.ID, execution.CreateOpts{ + Bundle: r.BundlePath, + // Stdin: r.Stdin, + // Stdout: r.Stdout, + // Stderr: r.Stderr, + }) if err != nil { return nil, err } - s.supervisor.Add(container.InitProcess()) + s.supervisor.Add(container) return &api.CreateContainerResponse{ Container: toGRPCContainer(container), }, nil } -func (s *Service) Delete(ctx context.Context, r *api.DeleteContainerRequest) (*api.Empty, error) { - if err := s.executor.Delete(r.ID); err != nil { +func (s *Service) Delete(ctx context.Context, r *api.DeleteContainerRequest) (*google_protobuf.Empty, error) { + container, err := s.executor.Load(r.ID) + if err != nil { + return nil, err + } + + if err = s.executor.Delete(container); err != nil { return nil, err } return nil, nil } -func (s *Service) List(ctx context.Context, r *api.ListContainerRequest) (*api.ListContainerResponse, error) { +func (s *Service) List(ctx context.Context, r *api.ListContainersRequest) (*api.ListContainersResponse, error) { containers, err := s.executor.List() if err != nil { return nil, err } + resp := &api.ListContainersResponse{} for _, c := range containers { - r.Containers = append(r.Containers, toGRPCContainer(c)) + resp.Containers = append(resp.Containers, toGRPCContainer(c)) } - return r, nil + return resp, nil } func (s *Service) Get(ctx context.Context, r *api.GetContainerRequest) (*api.GetContainerResponse, error) { container, err := s.executor.Load(r.ID) @@ -67,111 +82,94 @@ func (s *Service) Get(ctx context.Context, r *api.GetContainerRequest) (*api.Get }, nil } -func (s *Service) Update(ctx context.Context, r *api.UpdateContainerRequest) (*api.Empty, error) { +func (s *Service) Update(ctx context.Context, r *api.UpdateContainerRequest) (*google_protobuf.Empty, error) { return nil, nil } -func (s *Service) Pause(ctx context.Context, r *api.PauseContainerRequest) (*api.Empty, error) { +func (s *Service) Pause(ctx context.Context, r *api.PauseContainerRequest) (*google_protobuf.Empty, error) { container, err := s.executor.Load(r.ID) if err != nil { return nil, err } - return nil, container.Pause() + return nil, s.executor.Pause(container) } -func (s *Service) Resume(ctx context.Context, r *api.ResumeContainerRequest) (*api.Empty, error) { +func (s *Service) Resume(ctx context.Context, r *api.ResumeContainerRequest) (*google_protobuf.Empty, error) { container, err := s.executor.Load(r.ID) if err != nil { return nil, err } - return nil, container.Resume() + return nil, s.executor.Resume(container) } -func (s *Service) CreateProcess(ctx context.Context, r *api.CreateProcessRequest) (*api.CreateProcessResponse, error) { - container, err := s.executor.Load(r.ID) +func (s *Service) StartProcess(ctx context.Context, r *api.StartProcessRequest) (*api.StartProcessResponse, error) { + container, err := s.executor.Load(r.ContainerId) if err != nil { return nil, err } - process, err := container.CreateProcess(r.Process) + // TODO: generate spec + var spec specs.Process + // TODO: open IOs + process, err := s.executor.StartProcess(container, execution.CreateProcessOpts{ + Spec: spec, + // Stdin: r.Stdin, + // Stdout: r.Stdout, + // Stderr: r.Stderr, + }) if err != nil { return nil, err } s.supervisor.Add(process) - r.Process.Pid = process.Pid() - return &api.CreateProcessResponse{ - Process: r.Process, + return &api.StartProcessResponse{ + Process: toGRPCProcess(process), }, nil } // containerd managed execs + system pids forked in container func (s *Service) GetProcess(ctx context.Context, r *api.GetProcessRequest) (*api.GetProcessResponse, error) { - container, err := s.executor.Load(r.ID) + container, err := s.executor.Load(r.Container.ID) if err != nil { return nil, err } - process, err := container.Process(r.ProcessId) - if err != nil { - return nil, err + process := s.executor.GetProcess(r.Pid) + if process == nil { + return nil, fmt.Errorf("Make me a constant! Process not foumd!") } return &api.GetProcessResponse{ - Process: process, + Process: toGRPCProcess(process), }, nil } -func (s *Service) StartProcess(ctx context.Context, r *api.StartProcessRequest) (*api.StartProcessResponse, error) { - container, err := s.executor.Load(r.ID) +func (s *Service) SignalProcess(ctx context.Context, r *api.SignalProcessRequest) (*google_protobuf.Empty, error) { + container, err := s.executor.Load(r.Container.ID) if err != nil { return nil, err } - process, err := container.Process(r.Process.ID) - if err != nil { - return nil, err - } - if err := process.Start(); err != nil { - return nil, err - } - return &api.StartProcessRequest{ - Process: process, - }, nil + return nil, s.executor.SignalProcess(container, r.Process.ID, r.Signal) } -func (s *Service) SignalProcess(ctx context.Context, r *api.SignalProcessRequest) (*api.Empty, error) { - container, err := s.executor.Load(r.ID) +func (s *Service) DeleteProcess(ctx context.Context, r *api.DeleteProcessRequest) (*google_protobuf.Empty, error) { + container, err := s.executor.Load(r.Container.ID) if err != nil { return nil, err } - process, err := container.Process(r.Process.ID) - if err != nil { - return nil, err - } - return nil, process.Signal(r.Signal) -} - -func (s *Service) DeleteProcess(ctx context.Context, r *api.DeleteProcessRequest) (*api.Empty, error) { - container, err := s.executor.Load(r.ID) - if err != nil { - return nil, err - } - if err := container.DeleteProcess(r.Process.ID); err != nil { + if err := s.executor.DeleteProcess(container, r.Process.ID); err != nil { return nil, err } return nil, nil } func (s *Service) ListProcesses(ctx context.Context, r *api.ListProcessesRequest) (*api.ListProcessesResponse, error) { - container, err := s.executor.Load(r.ID) - if err != nil { - return nil, err - } - processes, err := container.Processes() + container, err := s.executor.Load(r.Container.ID) if err != nil { return nil, err } + processes := container.Processes() return &api.ListProcessesResponse{ - Processes: processes, + Processes: toGRPCProcesses(processes), }, nil }