Add container start and supervisor

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-12-05 15:38:32 -08:00
parent e620833c9e
commit 21a53c1d70
11 changed files with 380 additions and 139 deletions

View File

@ -55,6 +55,14 @@ func (x Status) String() string {
}
func (Status) EnumDescriptor() ([]byte, []int) { return fileDescriptorContainer, []int{0} }
type StartContainerRequest struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
}
func (m *StartContainerRequest) Reset() { *m = StartContainerRequest{} }
func (*StartContainerRequest) ProtoMessage() {}
func (*StartContainerRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{0} }
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"`
@ -65,7 +73,7 @@ type StartProcessRequest struct {
func (m *StartProcessRequest) Reset() { *m = StartProcessRequest{} }
func (*StartProcessRequest) ProtoMessage() {}
func (*StartProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{0} }
func (*StartProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{1} }
type StartProcessResponse struct {
Process *Process `protobuf:"bytes,1,opt,name=process" json:"process,omitempty"`
@ -73,7 +81,7 @@ type StartProcessResponse struct {
func (m *StartProcessResponse) Reset() { *m = StartProcessResponse{} }
func (*StartProcessResponse) ProtoMessage() {}
func (*StartProcessResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{1} }
func (*StartProcessResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{2} }
type Container struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
@ -84,7 +92,7 @@ type Container struct {
func (m *Container) Reset() { *m = Container{} }
func (*Container) ProtoMessage() {}
func (*Container) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{2} }
func (*Container) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{3} }
type Process struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
@ -100,7 +108,7 @@ type Process struct {
func (m *Process) Reset() { *m = Process{} }
func (*Process) ProtoMessage() {}
func (*Process) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{3} }
func (*Process) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{4} }
type User struct {
Uid uint32 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid,omitempty"`
@ -110,7 +118,7 @@ type User struct {
func (m *User) Reset() { *m = User{} }
func (*User) ProtoMessage() {}
func (*User) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{4} }
func (*User) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{5} }
type GetContainerRequest struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
@ -118,7 +126,7 @@ type GetContainerRequest struct {
func (m *GetContainerRequest) Reset() { *m = GetContainerRequest{} }
func (*GetContainerRequest) ProtoMessage() {}
func (*GetContainerRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{5} }
func (*GetContainerRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{6} }
type GetContainerResponse struct {
Container *Container `protobuf:"bytes,1,opt,name=container" json:"container,omitempty"`
@ -126,7 +134,7 @@ type GetContainerResponse struct {
func (m *GetContainerResponse) Reset() { *m = GetContainerResponse{} }
func (*GetContainerResponse) ProtoMessage() {}
func (*GetContainerResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{6} }
func (*GetContainerResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{7} }
type UpdateContainerRequest struct {
Container *Container `protobuf:"bytes,1,opt,name=container" json:"container,omitempty"`
@ -135,7 +143,7 @@ type UpdateContainerRequest struct {
func (m *UpdateContainerRequest) Reset() { *m = UpdateContainerRequest{} }
func (*UpdateContainerRequest) ProtoMessage() {}
func (*UpdateContainerRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{7} }
func (*UpdateContainerRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{8} }
type PauseContainerRequest struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
@ -143,7 +151,7 @@ type PauseContainerRequest struct {
func (m *PauseContainerRequest) Reset() { *m = PauseContainerRequest{} }
func (*PauseContainerRequest) ProtoMessage() {}
func (*PauseContainerRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{8} }
func (*PauseContainerRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{9} }
type ResumeContainerRequest struct {
ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
@ -151,7 +159,7 @@ type ResumeContainerRequest struct {
func (m *ResumeContainerRequest) Reset() { *m = ResumeContainerRequest{} }
func (*ResumeContainerRequest) ProtoMessage() {}
func (*ResumeContainerRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{9} }
func (*ResumeContainerRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{10} }
type GetProcessRequest struct {
Container *Container `protobuf:"bytes,1,opt,name=container" json:"container,omitempty"`
@ -160,7 +168,7 @@ type GetProcessRequest struct {
func (m *GetProcessRequest) Reset() { *m = GetProcessRequest{} }
func (*GetProcessRequest) ProtoMessage() {}
func (*GetProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{10} }
func (*GetProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{11} }
type GetProcessResponse struct {
Process *Process `protobuf:"bytes,1,opt,name=process" json:"process,omitempty"`
@ -168,7 +176,7 @@ type GetProcessResponse struct {
func (m *GetProcessResponse) Reset() { *m = GetProcessResponse{} }
func (*GetProcessResponse) ProtoMessage() {}
func (*GetProcessResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{11} }
func (*GetProcessResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{12} }
type SignalProcessRequest struct {
Container *Container `protobuf:"bytes,1,opt,name=container" json:"container,omitempty"`
@ -178,7 +186,7 @@ type SignalProcessRequest struct {
func (m *SignalProcessRequest) Reset() { *m = SignalProcessRequest{} }
func (*SignalProcessRequest) ProtoMessage() {}
func (*SignalProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{12} }
func (*SignalProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{13} }
type DeleteProcessRequest struct {
Container *Container `protobuf:"bytes,1,opt,name=container" json:"container,omitempty"`
@ -187,7 +195,7 @@ type DeleteProcessRequest struct {
func (m *DeleteProcessRequest) Reset() { *m = DeleteProcessRequest{} }
func (*DeleteProcessRequest) ProtoMessage() {}
func (*DeleteProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{13} }
func (*DeleteProcessRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{14} }
type ListProcessesRequest struct {
Container *Container `protobuf:"bytes,1,opt,name=container" json:"container,omitempty"`
@ -195,7 +203,7 @@ type ListProcessesRequest struct {
func (m *ListProcessesRequest) Reset() { *m = ListProcessesRequest{} }
func (*ListProcessesRequest) ProtoMessage() {}
func (*ListProcessesRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{14} }
func (*ListProcessesRequest) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{15} }
type ListProcessesResponse struct {
Processes []*Process `protobuf:"bytes,1,rep,name=processes" json:"processes,omitempty"`
@ -203,9 +211,10 @@ type ListProcessesResponse struct {
func (m *ListProcessesResponse) Reset() { *m = ListProcessesResponse{} }
func (*ListProcessesResponse) ProtoMessage() {}
func (*ListProcessesResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{15} }
func (*ListProcessesResponse) Descriptor() ([]byte, []int) { return fileDescriptorContainer, []int{16} }
func init() {
proto.RegisterType((*StartContainerRequest)(nil), "containerd.v1.StartContainerRequest")
proto.RegisterType((*StartProcessRequest)(nil), "containerd.v1.StartProcessRequest")
proto.RegisterType((*StartProcessResponse)(nil), "containerd.v1.StartProcessResponse")
proto.RegisterType((*Container)(nil), "containerd.v1.Container")
@ -224,6 +233,16 @@ func init() {
proto.RegisterType((*ListProcessesResponse)(nil), "containerd.v1.ListProcessesResponse")
proto.RegisterEnum("containerd.v1.Status", Status_name, Status_value)
}
func (this *StartContainerRequest) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 5)
s = append(s, "&execution.StartContainerRequest{")
s = append(s, "ID: "+fmt.Sprintf("%#v", this.ID)+",\n")
s = append(s, "}")
return strings.Join(s, "")
}
func (this *StartProcessRequest) GoString() string {
if this == nil {
return "nil"
@ -476,6 +495,7 @@ 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)
Start(ctx context.Context, in *StartContainerRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, 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)
@ -527,6 +547,15 @@ func (c *containerServiceClient) Resume(ctx context.Context, in *ResumeContainer
return out, nil
}
func (c *containerServiceClient) Start(ctx context.Context, in *StartContainerRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
out := new(google_protobuf.Empty)
err := grpc.Invoke(ctx, "/containerd.v1.ContainerService/Start", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
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...)
@ -579,6 +608,7 @@ 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)
Start(context.Context, *StartContainerRequest) (*google_protobuf.Empty, error)
StartProcess(context.Context, *StartProcessRequest) (*StartProcessResponse, error)
GetProcess(context.Context, *GetProcessRequest) (*GetProcessResponse, error)
SignalProcess(context.Context, *SignalProcessRequest) (*google_protobuf.Empty, error)
@ -662,6 +692,24 @@ func _ContainerService_Resume_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler)
}
func _ContainerService_Start_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(StartContainerRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ContainerServiceServer).Start(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/containerd.v1.ContainerService/Start",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ContainerServiceServer).Start(ctx, req.(*StartContainerRequest))
}
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 {
@ -772,6 +820,10 @@ var _ContainerService_serviceDesc = grpc.ServiceDesc{
MethodName: "Resume",
Handler: _ContainerService_Resume_Handler,
},
{
MethodName: "Start",
Handler: _ContainerService_Start_Handler,
},
{
MethodName: "StartProcess",
Handler: _ContainerService_StartProcess_Handler,
@ -797,6 +849,30 @@ var _ContainerService_serviceDesc = grpc.ServiceDesc{
Metadata: "container.proto",
}
func (m *StartContainerRequest) 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 *StartContainerRequest) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.ID) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintContainer(dAtA, i, uint64(len(m.ID)))
i += copy(dAtA[i:], m.ID)
}
return i, nil
}
func (m *StartProcessRequest) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@ -1423,6 +1499,16 @@ func encodeVarintContainer(dAtA []byte, offset int, v uint64) int {
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *StartContainerRequest) Size() (n int) {
var l int
_ = l
l = len(m.ID)
if l > 0 {
n += 1 + l + sovContainer(uint64(l))
}
return n
}
func (m *StartProcessRequest) Size() (n int) {
var l int
_ = l
@ -1684,6 +1770,16 @@ func sovContainer(x uint64) (n int) {
func sozContainer(x uint64) (n int) {
return sovContainer(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (this *StartContainerRequest) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&StartContainerRequest{`,
`ID:` + fmt.Sprintf("%v", this.ID) + `,`,
`}`,
}, "")
return s
}
func (this *StartProcessRequest) String() string {
if this == nil {
return "nil"
@ -1874,6 +1970,85 @@ func valueToStringContainer(v interface{}) string {
pv := reflect.Indirect(rv).Interface()
return fmt.Sprintf("*%v", pv)
}
func (m *StartContainerRequest) 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: StartContainerRequest: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: StartContainerRequest: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowContainer
}
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 ErrInvalidLengthContainer
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ID = string(dAtA[iNdEx:postIndex])
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 *StartProcessRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -3882,58 +4057,59 @@ var (
func init() { proto.RegisterFile("container.proto", fileDescriptorContainer) }
var fileDescriptorContainer = []byte{
// 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,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xec,
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,
// 855 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xc4, 0x56, 0xdd, 0x6e, 0xeb, 0x44,
0x10, 0xee, 0xc6, 0xa9, 0xd3, 0x4c, 0x8e, 0x0f, 0x61, 0x9b, 0x46, 0x56, 0x40, 0x39, 0x39, 0xe6,
0x00, 0x11, 0x52, 0x93, 0x12, 0x10, 0x37, 0x5c, 0xb5, 0x4d, 0x08, 0x95, 0x4a, 0x08, 0x9b, 0x46,
0x48, 0x48, 0xa8, 0x72, 0xe3, 0x25, 0xb5, 0x94, 0xda, 0xae, 0xbd, 0x2e, 0x70, 0xd7, 0xc7, 0xe0,
0x05, 0xe0, 0x9a, 0xc7, 0xe8, 0x25, 0x97, 0x5c, 0x21, 0x9a, 0x27, 0xe0, 0x11, 0xd0, 0xae, 0x7f,
0x92, 0xd8, 0x4e, 0x08, 0x05, 0xe9, 0xdc, 0xcd, 0x8c, 0x67, 0x3e, 0x7f, 0xdf, 0x78, 0x67, 0xd6,
0xf0, 0xc6, 0xc4, 0xb6, 0x98, 0x6e, 0x5a, 0xd4, 0x6d, 0x39, 0xae, 0xcd, 0x6c, 0xac, 0xc4, 0x01,
0xa3, 0x75, 0xf7, 0x61, 0xed, 0xad, 0xa9, 0x6d, 0x4f, 0x67, 0xb4, 0x2d, 0x1e, 0x5e, 0xf9, 0xdf,
0xb5, 0xe9, 0x8d, 0xc3, 0x7e, 0x0c, 0x72, 0x6b, 0x95, 0xa9, 0x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, 0xd7, 0xaa, 0xad, 0xe0, 0xb2, 0x6f, 0x45, 0x97, 0x7d, 0xab, 0xc7, 0x2f, 0x7b, 0xdc,
0x83, 0x5d, 0x31, 0xb1, 0xf8, 0x55, 0xb2, 0x2d, 0x59, 0x73, 0xbc, 0x16, 0xa6, 0x0f, 0x72, 0x30,
0xc7, 0x29, 0x3e, 0xd9, 0xe3, 0xbd, 0x89, 0x8f, 0xb8, 0x7c, 0x53, 0x7c, 0x32, 0x7f, 0x3b, 0xd6,
0xc2, 0x7c, 0x0d, 0xcf, 0x96, 0xef, 0xf0, 0x54, 0xe3, 0x33, 0x7e, 0x49, 0x52, 0x8d, 0xcf, 0xfc,
0x09, 0xf8, 0x0a, 0x60, 0xb1, 0x1f, 0x70, 0x23, 0xfd, 0xad, 0x12, 0xa0, 0x2f, 0x37, 0x64, 0x84,
0x90, 0xe7, 0xa0, 0xac, 0x6c, 0x0a, 0x9c, 0x22, 0x92, 0xb1, 0x47, 0xd6, 0x2a, 0x3f, 0x07, 0x65,
0x65, 0xb8, 0x53, 0x68, 0x59, 0xa3, 0xbf, 0x16, 0xed, 0x1b, 0x50, 0x56, 0x06, 0x2b, 0x85, 0x96,
0x35, 0xc6, 0xb5, 0x57, 0x9b, 0x93, 0x02, 0xdd, 0x27, 0x6f, 0x3f, 0x3c, 0xd6, 0x77, 0x7e, 0x7f,
0xac, 0xef, 0xfc, 0xf5, 0x58, 0x47, 0xf7, 0xf3, 0x3a, 0x7a, 0x98, 0xd7, 0xd1, 0x6f, 0xf3, 0x3a,
0xfa, 0x73, 0x5e, 0x47, 0x57, 0xb2, 0x60, 0xf2, 0xd1, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x81,
0x9a, 0x9a, 0xae, 0xc5, 0x0a, 0x00, 0x00,
}

View File

@ -10,6 +10,7 @@ service ContainerService {
rpc Update(UpdateContainerRequest) returns (google.protobuf.Empty);
rpc Pause(PauseContainerRequest) returns (google.protobuf.Empty);
rpc Resume(ResumeContainerRequest) returns (google.protobuf.Empty);
rpc Start(StartContainerRequest) returns (google.protobuf.Empty);
rpc StartProcess(StartProcessRequest) returns (StartProcessResponse);
rpc GetProcess(GetProcessRequest) returns (GetProcessResponse);
@ -18,6 +19,10 @@ service ContainerService {
rpc ListProcesses(ListProcessesRequest) returns (ListProcessesResponse);
}
message StartContainerRequest {
string id = 1 [(gogoproto.customname) = "ID"];
}
message StartProcessRequest {
string container_id = 1;
Process process = 2;

View File

@ -16,6 +16,7 @@
DeleteContainerResponse
ListContainersRequest
ListContainersResponse
StartContainerRequest
StartProcessRequest
StartProcessResponse
Container

View File

@ -1,14 +1,64 @@
package execution
import "fmt"
func NewContainer(stateRoot, id, bundle string) (*Container, error) {
stateDir, err := NewStateDir(stateRoot, id)
if err != nil {
return nil, err
}
return &Container{
id: id,
bundle: bundle,
stateDir: stateDir,
processes: make(map[string]Process),
}, nil
}
func LoadContainer(dir StateDir, id, bundle string, initPid int) *Container {
return &Container{
id: id,
stateDir: dir,
bundle: bundle,
initPid: initPid,
processes: make(map[string]Process),
}
}
type Container struct {
ID string
Bundle string
StateDir StateDir
id string
bundle string
stateDir StateDir
initPid int
processes map[string]Process
}
func (c *Container) AddProcess(p Process) {
func (c *Container) ID() string {
return c.id
}
func (c *Container) Bundle() string {
return c.bundle
}
func (c *Container) StateDir() StateDir {
return c.stateDir
}
func (c *Container) Wait() (uint32, error) {
for _, p := range c.processes {
if p.Pid() == c.initPid {
return p.Wait()
}
}
return nil, fmt.Errorf("no init process")
}
func (c *Container) AddProcess(p Process, isInit bool) {
if isInit {
c.initPid = p.Pid()
}
c.processes[p.ID()] = p
}

View File

@ -29,6 +29,7 @@ type Executor interface {
List() ([]*Container, error)
Load(id string) (*Container, error)
Delete(*Container) error
Start(*Container) error
StartProcess(*Container, CreateProcessOpts) (Process, error)
SignalProcess(*Container, os.Signal) error

View File

@ -29,21 +29,19 @@ type OCIRuntime struct {
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 {
func (r *OCIRuntime) Create(id string, o execution.CreateOpts) (container *execution.Container, err error) {
if container, err = execution.NewContainer(r.root, id, o.Bundle); err != nil {
return nil, err
}
initStateDir, err := stateDir.NewProcess()
if err != nil {
return nil, err
}
// /run/runc/redis/1/pid
pidFile := filepath.Join(initStateDir, "pid")
defer func() {
if err != nil {
container.StateDir().Delete()
}
}()
var (
initDir = container.StateDir().NewProcess()
pidFile = filepath.Join(initDir, "pid")
)
err = r.runc.Create(id, o.Bundle, &runc.CreateOpts{
Pidfile: pidfile,
Stdin: o.Stdin,
@ -55,40 +53,40 @@ func (r *OCIRuntime) Create(id string, o execution.CreateOpts) (*execution.Conta
}
pid, err := runc.ReadPifFile(pidfile)
if err != nil {
// TODO: kill the container if we are going to return
return nil, err
}
process, err := newProcess(pid)
process, err := newProcess(filepath.Base(initDir), pid)
if err != nil {
return nil, err
}
container := &execution.Container{
ID: id,
Bundle: o.Bundle,
StateDir: stateDir,
}
container.AddProcess(process)
container.AddProcess(process, true)
return container, nil
}
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)),
}
container := execution.LoadContainer(
execution.StateDir(filepath.Join(r.root, runcC.ID)),
runcC.ID,
runcC.Bundle,
)
process, err := newProcess(runcC.Pid)
dirs, err := ioutil.ReadDir(filepath.Join(container.StateDir().Processes()))
if err != nil {
return nil, err
}
container.AddProcess(process)
// /run/containerd/container-id/processess/process-id
dirs, err := ioutil.ReadDir(filepath.Join(container.Root))
if err != nil {
return nil, err
for _, d := range dirs {
pid, err := runc.ReadPidFile(filepath.Join(d, "pid"))
if err != nil {
return nil, err
}
process, err := newProcess(filepath.Base(d), pid)
if err != nil {
return nil, err
}
container.AddProcess(process, pid == runcC.Pid)
}
return container, nil
@ -171,7 +169,7 @@ func (r *OCIRuntime) StartProcess(c *execution.Container, o CreateProcessOpts) (
return nil, err
}
container.AddProcess(process)
container.AddProcess(process, false)
return process, nil
}

View File

@ -7,20 +7,26 @@ import (
"github.com/docker/containerd/execution"
)
func newProcess(pid int) (execution.Process, error) {
func newProcess(id string, pid int) (execution.Process, error) {
proc, err := os.FindProcess(pid)
if err != nil {
return nil, err
}
return &process{
id: id,
proc: proc,
}, nil
}
type process struct {
id string
proc *os.Process
}
func (p *process) ID() string {
return p.id
}
func (p *process) Pid() int {
return p.proc.Pid
}
@ -30,6 +36,7 @@ func (p *process) Wait() (uint32, error) {
if err != nil {
return 0, nil
}
// TODO: implement kill-all if we are the init pid
return uint32(state.Sys().(syscall.WaitStatus).ExitStatus()), nil
}

View File

@ -1,18 +1,11 @@
package execution
import (
"os"
"github.com/opencontainers/runtime-spec/specs-go"
)
import "os"
type Process interface {
ID() string
Pid() int64
Spec() *specs.Process
Start() error
Status() (Status, error)
//Spec() *specs.Process
Wait() (uint32, error)
Signal(os.Signal) error
}

View File

@ -99,6 +99,14 @@ func (s *Service) Resume(ctx context.Context, r *api.ResumeContainerRequest) (*g
return nil, s.executor.Resume(container)
}
func (s *Service) Start(ctx context.Context, r *api.StartContainerRequest) (*google_protobuf.Empty, error) {
container, err := s.executor.Load(r.ID)
if err != nil {
return nil, err
}
return nil, s.executor.Start(container)
}
func (s *Service) StartProcess(ctx context.Context, r *api.StartProcessRequest) (*api.StartProcessResponse, error) {
container, err := s.executor.Load(r.ContainerId)
if err != nil {
@ -117,7 +125,6 @@ func (s *Service) StartProcess(ctx context.Context, r *api.StartProcessRequest)
if err != nil {
return nil, err
}
s.supervisor.Add(process)
return &api.StartProcessResponse{

View File

@ -12,17 +12,13 @@ type StateDir string
func NewStateDir(root, id string) (StateDir, error) {
path := filepath.Join(root, id)
err := os.Mkdir(path, 0700)
if err != nil {
if err := os.Mkdir(path, 0700); err != nil {
return "", err
}
err = os.Mkdir(filepath.Join(path, processesDir), 0700)
if err != nil {
if err := os.Mkdir(filepath.Join(path, processesDir), 0700); err != nil {
os.RemoveAll(path)
return "", err
}
return StateDir(path), err
}
@ -30,15 +26,8 @@ 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) NewProcess() (string, error) {
return ioutil.TempDir(s.processDir(), "")
}
func (s StateDir) ProcessDir(id string) string {
@ -46,23 +35,25 @@ func (s StateDir) ProcessDir(id string) string {
}
func (s StateDir) DeleteProcess(id string) error {
return os.RemoveAll(filepath.Join(string(s), id))
return os.RemoveAll(filepath.Join(s.processDir(), id))
}
func (s StateDir) Processes() ([]string, error) {
basepath := filepath.Join(string(s), processesDir)
dirs, err := ioutil.ReadDir(basepath)
procsDir := s.processDir()
dirs, err := ioutil.ReadDir(procsDir)
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()))
paths = append(paths, filepath.Join(procsDir, d.Name()))
}
}
return paths, nil
}
func (s StateDir) processDir() string {
return filepath.Join(string(s), processesDir)
}

12
execution/supervisor.go Normal file
View File

@ -0,0 +1,12 @@
package execution
type Supervisor struct {
}
type waiter interface {
Wait() (uint32, error)
}
func (s *Supervisor) Add(w waiter) {
}