diff --git a/api/shim/shim.pb.go b/api/shim/shim.pb.go index 4204c5b..00dde35 100644 --- a/api/shim/shim.pb.go +++ b/api/shim/shim.pb.go @@ -21,6 +21,9 @@ PtyRequest EventsRequest Event + StateRequest + StateResponse + Process */ package shim @@ -84,6 +87,27 @@ func (x EventType) String() string { } func (EventType) EnumDescriptor() ([]byte, []int) { return fileDescriptorShim, []int{0} } +type State int32 + +const ( + State_STOPPED State = 0 + State_RUNNING State = 1 +) + +var State_name = map[int32]string{ + 0: "STOPPED", + 1: "RUNNING", +} +var State_value = map[string]int32{ + "STOPPED": 0, + "RUNNING": 1, +} + +func (x State) String() string { + return proto.EnumName(State_name, int32(x)) +} +func (State) EnumDescriptor() ([]byte, []int) { return fileDescriptorShim, []int{1} } + type CreateRequest struct { ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Bundle string `protobuf:"bytes,2,opt,name=bundle,proto3" json:"bundle,omitempty"` @@ -115,6 +139,7 @@ func (*StartRequest) ProtoMessage() {} func (*StartRequest) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{2} } type DeleteRequest struct { + Pid uint32 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"` } func (m *DeleteRequest) Reset() { *m = DeleteRequest{} } @@ -130,11 +155,11 @@ func (*DeleteResponse) ProtoMessage() {} func (*DeleteResponse) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{4} } type ExecRequest struct { - ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Terminal bool `protobuf:"varint,2,opt,name=terminal,proto3" json:"terminal,omitempty"` - Stdin string `protobuf:"bytes,3,opt,name=stdin,proto3" json:"stdin,omitempty"` - Stdout string `protobuf:"bytes,4,opt,name=stdout,proto3" json:"stdout,omitempty"` - Stderr string `protobuf:"bytes,5,opt,name=stderr,proto3" json:"stderr,omitempty"` + Terminal bool `protobuf:"varint,1,opt,name=terminal,proto3" json:"terminal,omitempty"` + Stdin string `protobuf:"bytes,2,opt,name=stdin,proto3" json:"stdin,omitempty"` + Stdout string `protobuf:"bytes,3,opt,name=stdout,proto3" json:"stdout,omitempty"` + Stderr string `protobuf:"bytes,4,opt,name=stderr,proto3" json:"stderr,omitempty"` + SelinuxLabel string `protobuf:"bytes,5,opt,name=selinux_label,json=selinuxLabel,proto3" json:"selinux_label,omitempty"` User *User `protobuf:"bytes,6,opt,name=user" json:"user,omitempty"` Args []string `protobuf:"bytes,7,rep,name=args" json:"args,omitempty"` Env []string `protobuf:"bytes,8,rep,name=env" json:"env,omitempty"` @@ -143,7 +168,6 @@ type ExecRequest struct { Rlimits []*Rlimit `protobuf:"bytes,11,rep,name=rlimits" json:"rlimits,omitempty"` NoNewPrivileges bool `protobuf:"varint,12,opt,name=no_new_privileges,json=noNewPrivileges,proto3" json:"no_new_privileges,omitempty"` ApparmorProfile string `protobuf:"bytes,13,opt,name=apparmor_profile,json=apparmorProfile,proto3" json:"apparmor_profile,omitempty"` - SelinuxLabel string `protobuf:"bytes,14,opt,name=selinux_label,json=selinuxLabel,proto3" json:"selinux_label,omitempty"` } func (m *ExecRequest) Reset() { *m = ExecRequest{} } @@ -206,6 +230,31 @@ func (m *Event) Reset() { *m = Event{} } func (*Event) ProtoMessage() {} func (*Event) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{11} } +type StateRequest struct { +} + +func (m *StateRequest) Reset() { *m = StateRequest{} } +func (*StateRequest) ProtoMessage() {} +func (*StateRequest) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{12} } + +type StateResponse struct { + ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Processes []*Process `protobuf:"bytes,2,rep,name=processes" json:"processes,omitempty"` +} + +func (m *StateResponse) Reset() { *m = StateResponse{} } +func (*StateResponse) ProtoMessage() {} +func (*StateResponse) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{13} } + +type Process struct { + Pid uint32 `protobuf:"varint,1,opt,name=pid,proto3" json:"pid,omitempty"` + State State `protobuf:"varint,2,opt,name=state,proto3,enum=containerd.shim.v1.State" json:"state,omitempty"` +} + +func (m *Process) Reset() { *m = Process{} } +func (*Process) ProtoMessage() {} +func (*Process) Descriptor() ([]byte, []int) { return fileDescriptorShim, []int{14} } + func init() { proto.RegisterType((*CreateRequest)(nil), "containerd.shim.v1.CreateRequest") proto.RegisterType((*CreateResponse)(nil), "containerd.shim.v1.CreateResponse") @@ -219,7 +268,11 @@ func init() { proto.RegisterType((*PtyRequest)(nil), "containerd.shim.v1.PtyRequest") proto.RegisterType((*EventsRequest)(nil), "containerd.shim.v1.EventsRequest") proto.RegisterType((*Event)(nil), "containerd.shim.v1.Event") + proto.RegisterType((*StateRequest)(nil), "containerd.shim.v1.StateRequest") + proto.RegisterType((*StateResponse)(nil), "containerd.shim.v1.StateResponse") + proto.RegisterType((*Process)(nil), "containerd.shim.v1.Process") proto.RegisterEnum("containerd.shim.v1.EventType", EventType_name, EventType_value) + proto.RegisterEnum("containerd.shim.v1.State", State_name, State_value) } func (this *CreateRequest) GoString() string { if this == nil { @@ -261,8 +314,9 @@ func (this *DeleteRequest) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 4) + s := make([]string, 0, 5) s = append(s, "&shim.DeleteRequest{") + s = append(s, "Pid: "+fmt.Sprintf("%#v", this.Pid)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -280,13 +334,13 @@ func (this *ExecRequest) GoString() string { if this == nil { return "nil" } - s := make([]string, 0, 18) + s := make([]string, 0, 17) s = append(s, "&shim.ExecRequest{") - s = append(s, "ID: "+fmt.Sprintf("%#v", this.ID)+",\n") s = append(s, "Terminal: "+fmt.Sprintf("%#v", this.Terminal)+",\n") s = append(s, "Stdin: "+fmt.Sprintf("%#v", this.Stdin)+",\n") s = append(s, "Stdout: "+fmt.Sprintf("%#v", this.Stdout)+",\n") s = append(s, "Stderr: "+fmt.Sprintf("%#v", this.Stderr)+",\n") + s = append(s, "SelinuxLabel: "+fmt.Sprintf("%#v", this.SelinuxLabel)+",\n") if this.User != nil { s = append(s, "User: "+fmt.Sprintf("%#v", this.User)+",\n") } @@ -299,7 +353,6 @@ func (this *ExecRequest) GoString() string { } s = append(s, "NoNewPrivileges: "+fmt.Sprintf("%#v", this.NoNewPrivileges)+",\n") s = append(s, "ApparmorProfile: "+fmt.Sprintf("%#v", this.ApparmorProfile)+",\n") - s = append(s, "SelinuxLabel: "+fmt.Sprintf("%#v", this.SelinuxLabel)+",\n") s = append(s, "}") return strings.Join(s, "") } @@ -371,6 +424,39 @@ func (this *Event) GoString() string { s = append(s, "}") return strings.Join(s, "") } +func (this *StateRequest) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 4) + s = append(s, "&shim.StateRequest{") + s = append(s, "}") + return strings.Join(s, "") +} +func (this *StateResponse) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&shim.StateResponse{") + s = append(s, "ID: "+fmt.Sprintf("%#v", this.ID)+",\n") + if this.Processes != nil { + s = append(s, "Processes: "+fmt.Sprintf("%#v", this.Processes)+",\n") + } + s = append(s, "}") + return strings.Join(s, "") +} +func (this *Process) GoString() string { + if this == nil { + return "nil" + } + s := make([]string, 0, 6) + s = append(s, "&shim.Process{") + s = append(s, "Pid: "+fmt.Sprintf("%#v", this.Pid)+",\n") + s = append(s, "State: "+fmt.Sprintf("%#v", this.State)+",\n") + s = append(s, "}") + return strings.Join(s, "") +} func valueToGoStringShim(v interface{}, typ string) string { rv := reflect.ValueOf(v) if rv.IsNil() { @@ -415,6 +501,7 @@ type ShimClient interface { Exec(ctx context.Context, in *ExecRequest, opts ...grpc.CallOption) (*ExecResponse, error) Pty(ctx context.Context, in *PtyRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) Events(ctx context.Context, in *EventsRequest, opts ...grpc.CallOption) (Shim_EventsClient, error) + State(ctx context.Context, in *StateRequest, opts ...grpc.CallOption) (*StateResponse, error) } type shimClient struct { @@ -502,6 +589,15 @@ func (x *shimEventsClient) Recv() (*Event, error) { return m, nil } +func (c *shimClient) State(ctx context.Context, in *StateRequest, opts ...grpc.CallOption) (*StateResponse, error) { + out := new(StateResponse) + err := grpc.Invoke(ctx, "/containerd.shim.v1.Shim/State", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // Server API for Shim service type ShimServer interface { @@ -511,6 +607,7 @@ type ShimServer interface { Exec(context.Context, *ExecRequest) (*ExecResponse, error) Pty(context.Context, *PtyRequest) (*google_protobuf.Empty, error) Events(*EventsRequest, Shim_EventsServer) error + State(context.Context, *StateRequest) (*StateResponse, error) } func RegisterShimServer(s *grpc.Server, srv ShimServer) { @@ -628,6 +725,24 @@ func (x *shimEventsServer) Send(m *Event) error { return x.ServerStream.SendMsg(m) } +func _Shim_State_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ShimServer).State(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.shim.v1.Shim/State", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ShimServer).State(ctx, req.(*StateRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Shim_serviceDesc = grpc.ServiceDesc{ ServiceName: "containerd.shim.v1.Shim", HandlerType: (*ShimServer)(nil), @@ -652,6 +767,10 @@ var _Shim_serviceDesc = grpc.ServiceDesc{ MethodName: "Pty", Handler: _Shim_Pty_Handler, }, + { + MethodName: "State", + Handler: _Shim_State_Handler, + }, }, Streams: []grpc.StreamDesc{ { @@ -793,6 +912,11 @@ func (m *DeleteRequest) MarshalTo(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Pid != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintShim(dAtA, i, uint64(m.Pid)) + } return i, nil } @@ -834,14 +958,8 @@ func (m *ExecRequest) MarshalTo(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.ID) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintShim(dAtA, i, uint64(len(m.ID))) - i += copy(dAtA[i:], m.ID) - } if m.Terminal { - dAtA[i] = 0x10 + dAtA[i] = 0x8 i++ if m.Terminal { dAtA[i] = 1 @@ -851,23 +969,29 @@ func (m *ExecRequest) MarshalTo(dAtA []byte) (int, error) { i++ } if len(m.Stdin) > 0 { - dAtA[i] = 0x1a + dAtA[i] = 0x12 i++ i = encodeVarintShim(dAtA, i, uint64(len(m.Stdin))) i += copy(dAtA[i:], m.Stdin) } if len(m.Stdout) > 0 { - dAtA[i] = 0x22 + dAtA[i] = 0x1a i++ i = encodeVarintShim(dAtA, i, uint64(len(m.Stdout))) i += copy(dAtA[i:], m.Stdout) } if len(m.Stderr) > 0 { - dAtA[i] = 0x2a + dAtA[i] = 0x22 i++ i = encodeVarintShim(dAtA, i, uint64(len(m.Stderr))) i += copy(dAtA[i:], m.Stderr) } + if len(m.SelinuxLabel) > 0 { + dAtA[i] = 0x2a + i++ + i = encodeVarintShim(dAtA, i, uint64(len(m.SelinuxLabel))) + i += copy(dAtA[i:], m.SelinuxLabel) + } if m.User != nil { dAtA[i] = 0x32 i++ @@ -957,12 +1081,6 @@ func (m *ExecRequest) MarshalTo(dAtA []byte) (int, error) { i = encodeVarintShim(dAtA, i, uint64(len(m.ApparmorProfile))) i += copy(dAtA[i:], m.ApparmorProfile) } - if len(m.SelinuxLabel) > 0 { - dAtA[i] = 0x72 - i++ - i = encodeVarintShim(dAtA, i, uint64(len(m.SelinuxLabel))) - i += copy(dAtA[i:], m.SelinuxLabel) - } return i, nil } @@ -1158,6 +1276,88 @@ func (m *Event) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *StateRequest) 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 *StateRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + return i, nil +} + +func (m *StateResponse) 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 *StateResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ID) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintShim(dAtA, i, uint64(len(m.ID))) + i += copy(dAtA[i:], m.ID) + } + if len(m.Processes) > 0 { + for _, msg := range m.Processes { + dAtA[i] = 0x12 + i++ + i = encodeVarintShim(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + +func (m *Process) 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 *Process) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Pid != 0 { + dAtA[i] = 0x8 + i++ + i = encodeVarintShim(dAtA, i, uint64(m.Pid)) + } + if m.State != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintShim(dAtA, i, uint64(m.State)) + } + return i, nil +} + func encodeFixed64Shim(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) dAtA[offset+1] = uint8(v >> 8) @@ -1239,6 +1439,9 @@ func (m *StartRequest) Size() (n int) { func (m *DeleteRequest) Size() (n int) { var l int _ = l + if m.Pid != 0 { + n += 1 + sovShim(uint64(m.Pid)) + } return n } @@ -1254,10 +1457,6 @@ func (m *DeleteResponse) Size() (n int) { func (m *ExecRequest) Size() (n int) { var l int _ = l - l = len(m.ID) - if l > 0 { - n += 1 + l + sovShim(uint64(l)) - } if m.Terminal { n += 2 } @@ -1273,6 +1472,10 @@ func (m *ExecRequest) Size() (n int) { if l > 0 { n += 1 + l + sovShim(uint64(l)) } + l = len(m.SelinuxLabel) + if l > 0 { + n += 1 + l + sovShim(uint64(l)) + } if m.User != nil { l = m.User.Size() n += 1 + l + sovShim(uint64(l)) @@ -1312,10 +1515,6 @@ func (m *ExecRequest) Size() (n int) { if l > 0 { n += 1 + l + sovShim(uint64(l)) } - l = len(m.SelinuxLabel) - if l > 0 { - n += 1 + l + sovShim(uint64(l)) - } return n } @@ -1403,6 +1602,40 @@ func (m *Event) Size() (n int) { return n } +func (m *StateRequest) Size() (n int) { + var l int + _ = l + return n +} + +func (m *StateResponse) Size() (n int) { + var l int + _ = l + l = len(m.ID) + if l > 0 { + n += 1 + l + sovShim(uint64(l)) + } + if len(m.Processes) > 0 { + for _, e := range m.Processes { + l = e.Size() + n += 1 + l + sovShim(uint64(l)) + } + } + return n +} + +func (m *Process) Size() (n int) { + var l int + _ = l + if m.Pid != 0 { + n += 1 + sovShim(uint64(m.Pid)) + } + if m.State != 0 { + n += 1 + sovShim(uint64(m.State)) + } + return n +} + func sovShim(x uint64) (n int) { for { n++ @@ -1457,6 +1690,7 @@ func (this *DeleteRequest) String() string { return "nil" } s := strings.Join([]string{`&DeleteRequest{`, + `Pid:` + fmt.Sprintf("%v", this.Pid) + `,`, `}`, }, "") return s @@ -1476,11 +1710,11 @@ func (this *ExecRequest) String() string { return "nil" } s := strings.Join([]string{`&ExecRequest{`, - `ID:` + fmt.Sprintf("%v", this.ID) + `,`, `Terminal:` + fmt.Sprintf("%v", this.Terminal) + `,`, `Stdin:` + fmt.Sprintf("%v", this.Stdin) + `,`, `Stdout:` + fmt.Sprintf("%v", this.Stdout) + `,`, `Stderr:` + fmt.Sprintf("%v", this.Stderr) + `,`, + `SelinuxLabel:` + fmt.Sprintf("%v", this.SelinuxLabel) + `,`, `User:` + strings.Replace(fmt.Sprintf("%v", this.User), "User", "User", 1) + `,`, `Args:` + fmt.Sprintf("%v", this.Args) + `,`, `Env:` + fmt.Sprintf("%v", this.Env) + `,`, @@ -1489,7 +1723,6 @@ func (this *ExecRequest) String() string { `Rlimits:` + strings.Replace(fmt.Sprintf("%v", this.Rlimits), "Rlimit", "Rlimit", 1) + `,`, `NoNewPrivileges:` + fmt.Sprintf("%v", this.NoNewPrivileges) + `,`, `ApparmorProfile:` + fmt.Sprintf("%v", this.ApparmorProfile) + `,`, - `SelinuxLabel:` + fmt.Sprintf("%v", this.SelinuxLabel) + `,`, `}`, }, "") return s @@ -1562,6 +1795,37 @@ func (this *Event) String() string { }, "") return s } +func (this *StateRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&StateRequest{`, + `}`, + }, "") + return s +} +func (this *StateResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&StateResponse{`, + `ID:` + fmt.Sprintf("%v", this.ID) + `,`, + `Processes:` + strings.Replace(fmt.Sprintf("%v", this.Processes), "Process", "Process", 1) + `,`, + `}`, + }, "") + return s +} +func (this *Process) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Process{`, + `Pid:` + fmt.Sprintf("%v", this.Pid) + `,`, + `State:` + fmt.Sprintf("%v", this.State) + `,`, + `}`, + }, "") + return s +} func valueToStringShim(v interface{}) string { rv := reflect.ValueOf(v) if rv.IsNil() { @@ -1982,6 +2246,25 @@ func (m *DeleteRequest) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: DeleteRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Pid", wireType) + } + m.Pid = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShim + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Pid |= (uint32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipShim(dAtA[iNdEx:]) @@ -2102,35 +2385,6 @@ func (m *ExecRequest) Unmarshal(dAtA []byte) error { } 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 ErrIntOverflowShim - } - 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 ErrInvalidLengthShim - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ID = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Terminal", wireType) } @@ -2150,7 +2404,7 @@ func (m *ExecRequest) Unmarshal(dAtA []byte) error { } } m.Terminal = bool(v != 0) - case 3: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Stdin", wireType) } @@ -2179,7 +2433,7 @@ func (m *ExecRequest) Unmarshal(dAtA []byte) error { } m.Stdin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Stdout", wireType) } @@ -2208,7 +2462,7 @@ func (m *ExecRequest) Unmarshal(dAtA []byte) error { } m.Stdout = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Stderr", wireType) } @@ -2237,6 +2491,35 @@ func (m *ExecRequest) Unmarshal(dAtA []byte) error { } m.Stderr = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SelinuxLabel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShim + } + 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 ErrInvalidLengthShim + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SelinuxLabel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) @@ -2466,35 +2749,6 @@ func (m *ExecRequest) Unmarshal(dAtA []byte) error { } m.ApparmorProfile = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SelinuxLabel", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowShim - } - 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 ErrInvalidLengthShim - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SelinuxLabel = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipShim(dAtA[iNdEx:]) @@ -3145,6 +3399,254 @@ func (m *Event) Unmarshal(dAtA []byte) error { } return nil } +func (m *StateRequest) 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 ErrIntOverflowShim + } + 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: StateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipShim(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthShim + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StateResponse) 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 ErrIntOverflowShim + } + 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: StateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StateResponse: 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 ErrIntOverflowShim + } + 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 ErrInvalidLengthShim + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ID = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Processes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShim + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthShim + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Processes = append(m.Processes, &Process{}) + if err := m.Processes[len(m.Processes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipShim(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthShim + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Process) 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 ErrIntOverflowShim + } + 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: Process: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Process: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Pid", wireType) + } + m.Pid = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShim + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Pid |= (uint32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) + } + m.State = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowShim + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.State |= (State(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipShim(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthShim + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipShim(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 @@ -3253,60 +3755,66 @@ var ( func init() { proto.RegisterFile("shim.proto", fileDescriptorShim) } var fileDescriptorShim = []byte{ - // 868 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x54, 0x4d, 0x6f, 0xeb, 0x44, - 0x14, 0xad, 0x63, 0xe7, 0xa3, 0x37, 0x1f, 0x0d, 0xa3, 0xa7, 0x6a, 0x5e, 0x80, 0x34, 0x98, 0x05, - 0xe1, 0x09, 0xa5, 0xb4, 0xb0, 0x65, 0xd1, 0xd7, 0x58, 0xbc, 0x4a, 0x0f, 0x1a, 0x4d, 0x8a, 0xf4, - 0x76, 0x91, 0x53, 0x4f, 0x9d, 0x91, 0x1c, 0x8f, 0x99, 0x19, 0xa7, 0xcd, 0x8e, 0x0d, 0xbf, 0x8b, - 0x05, 0x9b, 0xb7, 0x64, 0x85, 0x58, 0x21, 0x9a, 0x5f, 0xc0, 0x4f, 0x40, 0x33, 0x76, 0x92, 0x7e, - 0x38, 0xbc, 0xdd, 0xbd, 0xc7, 0xd7, 0x77, 0xee, 0x3d, 0x73, 0xe6, 0x00, 0xc8, 0x19, 0x9b, 0x0f, - 0x12, 0xc1, 0x15, 0x47, 0xe8, 0x9a, 0xc7, 0xca, 0x67, 0x31, 0x15, 0xc1, 0xc0, 0xc0, 0x8b, 0x93, - 0xce, 0xc7, 0x21, 0xe7, 0x61, 0x44, 0x8f, 0x4d, 0xc5, 0x34, 0xbd, 0x39, 0xa6, 0xf3, 0x44, 0x2d, - 0xb3, 0x1f, 0x3a, 0x2f, 0x42, 0x1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0x4f, 0x1d, - 0x40, 0x07, 0x00, 0x00, + // 962 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x7c, 0x55, 0xcd, 0x6e, 0xe3, 0x36, + 0x10, 0x8e, 0x2c, 0xc5, 0x3f, 0xe3, 0xc8, 0x71, 0x89, 0x45, 0xa0, 0x78, 0x5b, 0xc7, 0x51, 0x0f, + 0x4d, 0x83, 0xc2, 0x69, 0xd2, 0x5e, 0x7a, 0xe8, 0x21, 0x1b, 0x0b, 0xbb, 0x01, 0xd2, 0xc4, 0x60, + 0xb2, 0xc0, 0xde, 0x0c, 0x39, 0x62, 0x6c, 0x02, 0xb2, 0xa4, 0x92, 0x94, 0x13, 0xdf, 0x7a, 0xe9, + 0xb1, 0x4f, 0xd2, 0x17, 0xd9, 0x63, 0x4f, 0x45, 0x4f, 0x45, 0xe3, 0x27, 0xe8, 0x23, 0x2c, 0x48, + 0x4a, 0xf6, 0x66, 0x23, 0xed, 0x6d, 0xe6, 0xd3, 0xa7, 0xe1, 0x7c, 0xc3, 0x99, 0x21, 0x00, 0x9f, + 0xd2, 0x59, 0x3f, 0x61, 0xb1, 0x88, 0x11, 0xba, 0x8d, 0x23, 0xe1, 0xd3, 0x88, 0xb0, 0xa0, 0xaf, + 0xe0, 0xf9, 0x71, 0xe7, 0xe5, 0x24, 0x8e, 0x27, 0x21, 0x39, 0x52, 0x8c, 0x71, 0x7a, 0x77, 0x44, + 0x66, 0x89, 0x58, 0xe8, 0x1f, 0x3a, 0x2f, 0x26, 0xf1, 0x24, 0x56, 0xe6, 0x91, 0xb4, 0x34, 0xea, + 0xfe, 0x6d, 0x80, 0x7d, 0xc6, 0x88, 0x2f, 0x08, 0x26, 0xbf, 0xa6, 0x84, 0x0b, 0xb4, 0x03, 0x15, + 0x1a, 0x38, 0x46, 0xcf, 0x38, 0x68, 0xbc, 0xaa, 0x2e, 0xff, 0xdd, 0xab, 0x9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 0x87, 0x51, 0xe8, 0x8f, 0x89, 0x2e, 0x71, 0x03, 0x6f, 0x65, 0xe0, 0x85, 0xc4, + 0xd0, 0x77, 0x60, 0xa5, 0x9c, 0x30, 0x55, 0xe5, 0xe6, 0x89, 0xd3, 0x7f, 0xde, 0x4f, 0xfd, 0xb7, + 0x9c, 0x30, 0xac, 0x58, 0x08, 0x81, 0xe5, 0xb3, 0x09, 0x77, 0x6a, 0x3d, 0xf3, 0xa0, 0x81, 0x95, + 0x2d, 0xab, 0x43, 0xa2, 0xb9, 0x53, 0x57, 0x90, 0x34, 0x25, 0x72, 0x7b, 0x1f, 0x38, 0x0d, 0x75, + 0x9c, 0x34, 0x91, 0x0b, 0x5b, 0xb7, 0x7e, 0xe2, 0x8f, 0x69, 0x48, 0x05, 0x25, 0xdc, 0x01, 0x45, + 0x7e, 0x82, 0xa1, 0x1f, 0xa1, 0xc6, 0x42, 0x3a, 0xa3, 0x82, 0x3b, 0xcd, 0x9e, 0x79, 0xd0, 0x3c, + 0xe9, 0x14, 0x25, 0x83, 0x15, 0x05, 0xe7, 0x54, 0x74, 0x08, 0x5f, 0x44, 0xf1, 0x28, 0x22, 0xf7, + 0xa3, 0x84, 0xd1, 0x39, 0x0d, 0xc9, 0x84, 0x70, 0x67, 0x4b, 0xd5, 0x73, 0x3b, 0x8a, 0x2f, 0xc9, + 0xfd, 0x70, 0x05, 0xa3, 0x6f, 0xa1, 0xed, 0x27, 0x89, 0xcf, 0x66, 0x31, 0x1b, 0x25, 0x2c, 0xbe, + 0xa3, 0x21, 0x71, 0x6c, 0x95, 0xe4, 0x76, 0x8e, 0x0f, 0x35, 0xec, 0x5e, 0x83, 0x25, 0x65, 0x4b, + 0x29, 0xe9, 0xfa, 0xea, 0x53, 0x1a, 0x48, 0x64, 0x42, 0x03, 0x75, 0x33, 0x36, 0x96, 0x26, 0xfa, + 0x06, 0xb6, 0xfd, 0x20, 0xa0, 0x82, 0xc6, 0x91, 0x1f, 0x8e, 0x26, 0x34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xf2, 0x4b, 0xee, 0x95, 0x77, 0x56, 0x16, 0x67, 0xff, 0x33, 0x0c, + 0x2d, 0xeb, 0xd5, 0x97, 0xef, 0x1f, 0xbb, 0x1b, 0xff, 0x3c, 0x76, 0x37, 0xfe, 0x7f, 0xec, 0x1a, + 0xbf, 0x2d, 0xbb, 0xc6, 0xfb, 0x65, 0xd7, 0xf8, 0x6b, 0xd9, 0x35, 0xfe, 0x5b, 0x76, 0x8d, 0x71, + 0x55, 0xa9, 0xf8, 0xe1, 0x43, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0d, 0xe7, 0x6c, 0xde, 0x6d, 0x08, + 0x00, 0x00, } diff --git a/api/shim/shim.proto b/api/shim/shim.proto index 5c99a25..1f7ef1c 100644 --- a/api/shim/shim.proto +++ b/api/shim/shim.proto @@ -12,6 +12,7 @@ service Shim { rpc Exec(ExecRequest) returns (ExecResponse); rpc Pty(PtyRequest) returns (google.protobuf.Empty); rpc Events(EventsRequest) returns (stream Event); + rpc State(StateRequest) returns (StateResponse); } message CreateRequest { @@ -33,6 +34,7 @@ message StartRequest { } message DeleteRequest { + uint32 pid = 1; } message DeleteResponse { @@ -40,11 +42,11 @@ message DeleteResponse { } message ExecRequest { - string id = 1 [(gogoproto.customname) = "ID"]; - bool terminal = 2; - string stdin = 3; - string stdout = 4; - string stderr = 5; + bool terminal = 1; + string stdin = 2; + string stdout = 3; + string stderr = 4; + string selinux_label = 5; User user = 6; repeated string args = 7; repeated string env = 8; @@ -53,7 +55,6 @@ message ExecRequest { repeated Rlimit rlimits = 11; bool no_new_privileges = 12; string apparmor_profile = 13; - string selinux_label = 14; } message User { @@ -95,3 +96,21 @@ message Event { uint32 pid = 3; uint32 exit_status = 4; } + +message StateRequest { +} + +message StateResponse { + string id = 1 [(gogoproto.customname) = "ID"]; + repeated Process processes = 2; +} + +enum State { + STOPPED = 0; + RUNNING = 1; +} + +message Process { + uint32 pid = 1; + State state = 2; +} diff --git a/cmd/ctr/shim.go b/cmd/ctr/shim.go index 65b6d1e..68c85bb 100644 --- a/cmd/ctr/shim.go +++ b/cmd/ctr/shim.go @@ -1,12 +1,14 @@ package main import ( + "bytes" + "encoding/json" "fmt" "io/ioutil" "log" "net" - "os/exec" - "syscall" + "os" + "strconv" "time" gocontext "context" @@ -14,6 +16,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/grpclog" + "github.com/Sirupsen/logrus" "github.com/crosbymichael/console" "github.com/docker/containerd/api/shim" "github.com/urfave/cli" @@ -46,16 +49,8 @@ var shimCommand = cli.Command{ shimStartCommand, shimDeleteCommand, shimEventsCommand, - }, - Action: func(context *cli.Context) error { - cmd := exec.Command("containerd-shim", "--debug") - cmd.SysProcAttr = &syscall.SysProcAttr{} - cmd.SysProcAttr.Setpgid = true - if err := cmd.Start(); err != nil { - return err - } - fmt.Println("new shim started @ ./shim.sock") - return nil + shimStateCommand, + shimExecCommand, }, } @@ -150,7 +145,13 @@ var shimDeleteCommand = cli.Command{ if err != nil { return err } - r, err := service.Delete(gocontext.Background(), &shim.DeleteRequest{}) + pid, err := strconv.Atoi(context.Args().First()) + if err != nil { + return err + } + r, err := service.Delete(gocontext.Background(), &shim.DeleteRequest{ + Pid: uint32(pid), + }) if err != nil { return err } @@ -159,6 +160,99 @@ var shimDeleteCommand = cli.Command{ }, } +var shimStateCommand = cli.Command{ + Name: "state", + Usage: "get the state of all the processes of the shim", + Action: func(context *cli.Context) error { + service, err := getShimService() + if err != nil { + return err + } + r, err := service.State(gocontext.Background(), &shim.StateRequest{}) + if err != nil { + return err + } + data, err := json.Marshal(r) + if err != nil { + return err + } + buf := bytes.NewBuffer(nil) + if err := json.Indent(buf, data, " ", " "); err != nil { + return err + } + buf.WriteTo(os.Stdout) + return nil + }, +} + +var shimExecCommand = cli.Command{ + Name: "exec", + Usage: "exec a new process in the shim's container", + Flags: append(fifoFlags, + cli.BoolFlag{ + Name: "attach,a", + Usage: "stay attached to the container and open the fifos", + }, + cli.StringSliceFlag{ + Name: "env,e", + Usage: "add environment vars", + Value: &cli.StringSlice{}, + }, + cli.StringFlag{ + Name: "cwd", + Usage: "current working directory", + }, + ), + Action: func(context *cli.Context) error { + service, err := getShimService() + if err != nil { + return err + } + tty := context.Bool("tty") + wg, err := prepareStdio(context.String("stdin"), context.String("stdout"), context.String("stderr"), tty) + if err != nil { + return err + } + rq := &shim.ExecRequest{ + Args: []string(context.Args()), + Env: context.StringSlice("env"), + Cwd: context.String("cwd"), + Stdin: context.String("stdin"), + Stdout: context.String("stdout"), + Stderr: context.String("stderr"), + Terminal: tty, + } + r, err := service.Exec(gocontext.Background(), rq) + if err != nil { + return err + } + fmt.Printf("exec running with pid %d\n", r.Pid) + if context.Bool("attach") { + logrus.Info("attaching") + if tty { + current := console.Current() + defer current.Reset() + if err := current.SetRaw(); err != nil { + return err + } + size, err := current.Size() + if err != nil { + return err + } + if _, err := service.Pty(gocontext.Background(), &shim.PtyRequest{ + Pid: r.Pid, + Width: uint32(size.Width), + Height: uint32(size.Height), + }); err != nil { + return err + } + } + wg.Wait() + } + return nil + }, +} + var shimEventsCommand = cli.Command{ Name: "events", Usage: "get events for a shim", diff --git a/cmd/ctr/utils.go b/cmd/ctr/utils.go index d3e7443..398033c 100644 --- a/cmd/ctr/utils.go +++ b/cmd/ctr/utils.go @@ -14,6 +14,7 @@ import ( gocontext "context" + "github.com/Sirupsen/logrus" "github.com/docker/containerd/api/execution" "github.com/tonistiigi/fifo" "github.com/urfave/cli" @@ -38,6 +39,7 @@ func prepareStdio(stdin, stdout, stderr string, console bool) (*sync.WaitGroup, }(f) go func(w io.WriteCloser) { io.Copy(w, os.Stdin) + logrus.Info("stdin copy finished") w.Close() }(f) @@ -54,6 +56,7 @@ func prepareStdio(stdin, stdout, stderr string, console bool) (*sync.WaitGroup, go func(r io.ReadCloser) { io.Copy(os.Stdout, r) r.Close() + logrus.Info("stdout copy finished") wg.Done() }(f) @@ -71,6 +74,7 @@ func prepareStdio(stdin, stdout, stderr string, console bool) (*sync.WaitGroup, go func(r io.ReadCloser) { io.Copy(os.Stderr, r) r.Close() + logrus.Info("stderr copy finished") wg.Done() }(f) } diff --git a/shim/exec.go b/shim/exec.go index 9492394..514c9ff 100644 --- a/shim/exec.go +++ b/shim/exec.go @@ -16,7 +16,7 @@ import ( type execProcess struct { sync.WaitGroup - id string + id int console console.Console io runc.IO status int @@ -25,19 +25,19 @@ type execProcess struct { parent *initProcess } -func newExecProcess(context context.Context, r *apishim.ExecRequest, parent *initProcess) (process, error) { +func newExecProcess(context context.Context, r *apishim.ExecRequest, parent *initProcess, id int) (process, error) { cwd, err := os.Getwd() if err != nil { return nil, err } e := &execProcess{ - id: r.ID, + id: id, parent: parent, } var ( socket *runc.ConsoleSocket io runc.IO - pidfile = filepath.Join(cwd, fmt.Sprintf("%s.pid", r.ID)) + pidfile = filepath.Join(cwd, fmt.Sprintf("%d.pid", id)) ) if r.Terminal { if socket, err = runc.NewConsoleSocket(filepath.Join(cwd, "pty.sock")); err != nil { @@ -56,9 +56,8 @@ func newExecProcess(context context.Context, r *apishim.ExecRequest, parent *ini ConsoleSocket: socket, IO: io, Detach: true, - Tty: socket != nil, } - if err := parent.runc.Exec(context, r.ID, processFromRequest(r), opts); err != nil { + if err := parent.runc.Exec(context, parent.id, processFromRequest(r), opts); err != nil { return nil, err } pid, err := runc.ReadPidFile(opts.PidFile) @@ -70,13 +69,15 @@ func newExecProcess(context context.Context, r *apishim.ExecRequest, parent *ini } func processFromRequest(r *apishim.ExecRequest) specs.Process { + var user specs.User + if r.User != nil { + user.UID = r.User.Uid + user.GID = r.User.Gid + user.AdditionalGids = r.User.AdditionalGids + } return specs.Process{ - Terminal: r.Terminal, - User: specs.User{ - UID: r.User.Uid, - GID: r.User.Gid, - AdditionalGids: r.User.AdditionalGids, - }, + Terminal: r.Terminal, + User: user, Rlimits: rlimits(r.Rlimits), Args: r.Args, Env: r.Env, @@ -115,6 +116,10 @@ func (e *execProcess) Exited(status int) { } } +func (e *execProcess) Delete(ctx context.Context) error { + return nil +} + func (e *execProcess) Resize(ws console.WinSize) error { if e.console == nil { return nil diff --git a/shim/process.go b/shim/process.go index 1376ca6..3f16fb1 100644 --- a/shim/process.go +++ b/shim/process.go @@ -1,6 +1,10 @@ package shim -import "github.com/crosbymichael/console" +import ( + "context" + + "github.com/crosbymichael/console" +) type process interface { // Pid returns the pid for the process @@ -11,4 +15,5 @@ type process interface { Exited(status int) // Status returns the exit status Status() int + Delete(context.Context) error } diff --git a/shim/service.go b/shim/service.go index c0e4d4b..4f286cc 100644 --- a/shim/service.go +++ b/shim/service.go @@ -3,6 +3,7 @@ package shim import ( "fmt" "sync" + "syscall" "github.com/crosbymichael/console" apishim "github.com/docker/containerd/api/shim" @@ -27,6 +28,7 @@ type Service struct { mu sync.Mutex processes map[int]process events chan *apishim.Event + execID int } func (s *Service) Create(ctx context.Context, r *apishim.CreateRequest) (*apishim.CreateResponse, error) { @@ -63,21 +65,28 @@ func (s *Service) Start(ctx context.Context, r *apishim.StartRequest) (*google_p } func (s *Service) Delete(ctx context.Context, r *apishim.DeleteRequest) (*apishim.DeleteResponse, error) { - if err := s.initProcess.Delete(ctx); err != nil { + s.mu.Lock() + p, ok := s.processes[int(r.Pid)] + s.mu.Unlock() + if !ok { + return nil, fmt.Errorf("process does not exist %d", r.Pid) + } + if err := p.Delete(ctx); err != nil { return nil, err } s.mu.Lock() - delete(s.processes, s.initProcess.pid) + delete(s.processes, p.Pid()) s.mu.Unlock() return &apishim.DeleteResponse{ - ExitStatus: uint32(s.initProcess.Status()), + ExitStatus: uint32(p.Status()), }, nil } func (s *Service) Exec(ctx context.Context, r *apishim.ExecRequest) (*apishim.ExecResponse, error) { s.mu.Lock() defer s.mu.Unlock() - process, err := newExecProcess(ctx, r, s.initProcess) + s.execID++ + process, err := newExecProcess(ctx, r, s.initProcess, s.execID) if err != nil { return nil, err } @@ -122,6 +131,29 @@ func (s *Service) Events(r *apishim.EventsRequest, stream apishim.Shim_EventsSer return nil } +func (s *Service) State(ctx context.Context, r *apishim.StateRequest) (*apishim.StateResponse, error) { + o := &apishim.StateResponse{ + ID: s.id, + Processes: []*apishim.Process{}, + } + s.mu.Lock() + defer s.mu.Unlock() + for _, p := range s.processes { + state := apishim.State_RUNNING + if err := syscall.Kill(p.Pid(), 0); err != nil { + if err != syscall.ESRCH { + return nil, err + } + state = apishim.State_STOPPED + } + o.Processes = append(o.Processes, &apishim.Process{ + Pid: uint32(p.Pid()), + State: state, + }) + } + return o, nil +} + func (s *Service) ProcessExit(e utils.Exit) error { s.mu.Lock() if p, ok := s.processes[e.Pid]; ok {