From 4764429cbe3eef4db35c4ec61b7247611483e579 Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Wed, 5 Apr 2017 09:03:07 +0800 Subject: [PATCH] Add kill API for execution service Signed-off-by: Qiang Huang --- api/services/execution/execution.pb.go | 311 +++++++++++++++++++++---- api/services/execution/execution.proto | 7 + container.go | 2 + linux/container.go | 8 + services/execution/service.go | 11 + 5 files changed, 300 insertions(+), 39 deletions(-) diff --git a/api/services/execution/execution.pb.go b/api/services/execution/execution.pb.go index ab58c91..1de463a 100644 --- a/api/services/execution/execution.pb.go +++ b/api/services/execution/execution.pb.go @@ -17,6 +17,7 @@ InfoRequest ListRequest ListResponse + KillRequest EventsRequest */ package execution @@ -123,12 +124,22 @@ func (m *ListResponse) Reset() { *m = ListResponse{} } func (*ListResponse) ProtoMessage() {} func (*ListResponse) Descriptor() ([]byte, []int) { return fileDescriptorExecution, []int{7} } +type KillRequest struct { + ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Signal uint32 `protobuf:"varint,2,opt,name=signal,proto3" json:"signal,omitempty"` + All bool `protobuf:"varint,3,opt,name=all,proto3" json:"all,omitempty"` +} + +func (m *KillRequest) Reset() { *m = KillRequest{} } +func (*KillRequest) ProtoMessage() {} +func (*KillRequest) Descriptor() ([]byte, []int) { return fileDescriptorExecution, []int{8} } + type EventsRequest struct { } func (m *EventsRequest) Reset() { *m = EventsRequest{} } func (*EventsRequest) ProtoMessage() {} -func (*EventsRequest) Descriptor() ([]byte, []int) { return fileDescriptorExecution, []int{8} } +func (*EventsRequest) Descriptor() ([]byte, []int) { return fileDescriptorExecution, []int{9} } func init() { proto.RegisterType((*CreateRequest)(nil), "containerd.v1.services.CreateRequest") @@ -139,6 +150,7 @@ func init() { proto.RegisterType((*InfoRequest)(nil), "containerd.v1.services.InfoRequest") proto.RegisterType((*ListRequest)(nil), "containerd.v1.services.ListRequest") proto.RegisterType((*ListResponse)(nil), "containerd.v1.services.ListResponse") + proto.RegisterType((*KillRequest)(nil), "containerd.v1.services.KillRequest") proto.RegisterType((*EventsRequest)(nil), "containerd.v1.services.EventsRequest") } @@ -158,6 +170,7 @@ type ContainerServiceClient interface { Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*DeleteResponse, error) Info(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*containerd_v1_types1.Container, error) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) + Kill(ctx context.Context, in *KillRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) Events(ctx context.Context, in *EventsRequest, opts ...grpc.CallOption) (ContainerService_EventsClient, error) } @@ -214,6 +227,15 @@ func (c *containerServiceClient) List(ctx context.Context, in *ListRequest, opts return out, nil } +func (c *containerServiceClient) Kill(ctx context.Context, in *KillRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) { + out := new(google_protobuf.Empty) + err := grpc.Invoke(ctx, "/containerd.v1.services.ContainerService/Kill", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *containerServiceClient) Events(ctx context.Context, in *EventsRequest, opts ...grpc.CallOption) (ContainerService_EventsClient, error) { stream, err := grpc.NewClientStream(ctx, &_ContainerService_serviceDesc.Streams[0], c.cc, "/containerd.v1.services.ContainerService/Events", opts...) if err != nil { @@ -254,6 +276,7 @@ type ContainerServiceServer interface { Delete(context.Context, *DeleteRequest) (*DeleteResponse, error) Info(context.Context, *InfoRequest) (*containerd_v1_types1.Container, error) List(context.Context, *ListRequest) (*ListResponse, error) + Kill(context.Context, *KillRequest) (*google_protobuf.Empty, error) Events(*EventsRequest, ContainerService_EventsServer) error } @@ -351,6 +374,24 @@ func _ContainerService_List_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _ContainerService_Kill_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(KillRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ContainerServiceServer).Kill(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.services.ContainerService/Kill", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ContainerServiceServer).Kill(ctx, req.(*KillRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _ContainerService_Events_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(EventsRequest) if err := stream.RecvMsg(m); err != nil { @@ -396,6 +437,10 @@ var _ContainerService_serviceDesc = grpc.ServiceDesc{ MethodName: "List", Handler: _ContainerService_List_Handler, }, + { + MethodName: "Kill", + Handler: _ContainerService_Kill_Handler, + }, }, Streams: []grpc.StreamDesc{ { @@ -665,6 +710,45 @@ func (m *ListResponse) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *KillRequest) 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 *KillRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.ID) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintExecution(dAtA, i, uint64(len(m.ID))) + i += copy(dAtA[i:], m.ID) + } + if m.Signal != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintExecution(dAtA, i, uint64(m.Signal)) + } + if m.All { + dAtA[i] = 0x18 + i++ + if m.All { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i++ + } + return i, nil +} + func (m *EventsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -823,6 +907,22 @@ func (m *ListResponse) Size() (n int) { return n } +func (m *KillRequest) Size() (n int) { + var l int + _ = l + l = len(m.ID) + if l > 0 { + n += 1 + l + sovExecution(uint64(l)) + } + if m.Signal != 0 { + n += 1 + sovExecution(uint64(m.Signal)) + } + if m.All { + n += 2 + } + return n +} + func (m *EventsRequest) Size() (n int) { var l int _ = l @@ -930,6 +1030,18 @@ func (this *ListResponse) String() string { }, "") return s } +func (this *KillRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&KillRequest{`, + `ID:` + fmt.Sprintf("%v", this.ID) + `,`, + `Signal:` + fmt.Sprintf("%v", this.Signal) + `,`, + `All:` + fmt.Sprintf("%v", this.All) + `,`, + `}`, + }, "") + return s +} func (this *EventsRequest) String() string { if this == nil { return "nil" @@ -1790,6 +1902,124 @@ func (m *ListResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *KillRequest) 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 ErrIntOverflowExecution + } + 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: KillRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: KillRequest: 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 ErrIntOverflowExecution + } + 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 ErrInvalidLengthExecution + } + 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 Signal", wireType) + } + m.Signal = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExecution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Signal |= (uint32(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field All", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowExecution + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + m.All = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipExecution(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthExecution + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *EventsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1950,42 +2180,45 @@ func init() { } var fileDescriptorExecution = []byte{ - // 586 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0xad, 0x93, 0xd4, 0x0d, 0x93, 0xa6, 0x54, 0xab, 0x28, 0x32, 0x46, 0x72, 0x23, 0xd3, 0x96, - 0x9c, 0x6c, 0x08, 0x37, 0x84, 0x90, 0x68, 0x13, 0xa1, 0x08, 0x8a, 0x84, 0x73, 0xe0, 0x88, 0x9c, - 0x78, 0x13, 0x56, 0x4a, 0x76, 0xcd, 0xee, 0x3a, 0x6a, 0x6e, 0xf0, 0xef, 0x7a, 0xe4, 0xc8, 0x09, - 0xd1, 0xfc, 0x0c, 0x4e, 0xc8, 0x6b, 0x3b, 0x1f, 0x25, 0xc6, 0x70, 0xb1, 0x66, 0x9e, 0x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c3, 0xf1, 0x8a, 0x3a, 0x48, - 0xae, 0x16, 0xfa, 0x00, 0x7a, 0x92, 0x01, 0x3a, 0x73, 0x76, 0x5f, 0x3e, 0x67, 0xeb, 0x37, 0x35, - 0xcf, 0x8b, 0x68, 0xa9, 0xfc, 0x1e, 0xec, 0xab, 0x80, 0xd0, 0x69, 0xde, 0xc0, 0x66, 0x7e, 0x66, - 0xf3, 0x8f, 0xff, 0xba, 0x17, 0x5f, 0xf1, 0x58, 0x5f, 0x12, 0x4b, 0xbe, 0xbe, 0xad, 0x7c, 0xf3, - 0xf5, 0xdd, 0x49, 0xf7, 0x0d, 0x54, 0xe2, 0x90, 0xd0, 0xa3, 0x3c, 0xfe, 0x46, 0x84, 0x66, 0x81, - 0xef, 0xe8, 0x3d, 0x54, 0xe2, 0xec, 0xf2, 0x3f, 0xb6, 0x11, 0xb4, 0x79, 0xfa, 0x77, 0x52, 0xaa, - 0xef, 0x0a, 0xf4, 0x24, 0xbe, 0xfc, 0xc5, 0xb7, 0xe2, 0x35, 0x77, 0xdf, 0x76, 0xc5, 0x79, 0xa2, - 0x5d, 0x18, 0x37, 0xb7, 0xd6, 0xde, 0xf7, 0x5b, 0x6b, 0xef, 0xcb, 0xd2, 0xd2, 0x6e, 0x96, 0x96, - 0xf6, 0x6d, 0x69, 0x69, 0x3f, 0x97, 0x96, 0x36, 0xd4, 0x95, 0xe3, 0xcf, 0x7e, 0x07, 0x00, 0x00, - 0xff, 0xff, 0x8d, 0x48, 0xca, 0x8b, 0xc5, 0x05, 0x00, 0x00, + // 629 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x54, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0xad, 0x93, 0xd4, 0x2d, 0x93, 0xa6, 0x54, 0xab, 0x2a, 0x5a, 0x8c, 0xe4, 0x46, 0xa6, 0x2d, + 0x39, 0xd9, 0x10, 0x6e, 0x08, 0x21, 0xd1, 0x0f, 0xa1, 0xaa, 0x14, 0x84, 0x7b, 0xe0, 0x88, 0xdc, + 0x64, 0x1b, 0x56, 0x72, 0x76, 0xcd, 0xee, 0xba, 0x6a, 0x6f, 0xf0, 0xcb, 0xb8, 0xf6, 0xc8, 0x91, + 0x13, 0xa2, 0xf9, 0x25, 0x68, 0xd7, 0x76, 0xea, 0x94, 0x18, 0xc3, 0xc5, 0x9a, 0x19, 0xcf, 0xec, + 0xcc, 0xbc, 0xf7, 0x76, 0xe1, 0xf5, 0x98, 0xaa, 0x4f, 0xe9, 0x99, 0x3f, 0xe4, 0x93, 0x60, 0xc8, + 0x99, 0x8a, 0x28, 0x23, 0x62, 0x54, 0x36, 0xa3, 0x84, 0x06, 0x92, 0x88, 0x0b, 0x3a, 0x24, 0x32, + 0x20, 0x97, 0x64, 0x98, 0x2a, 0xca, 0xd9, 0xad, 0xe5, 0x27, 0x82, 0x2b, 0x8e, 0xba, 0xb7, 0x25, + 0xfe, 0xc5, 0x53, 0xbf, 0xa8, 0x70, 0x1e, 0x8e, 0x39, 0x1f, 0xc7, 0x24, 0x30, 0x59, 0x67, 0xe9, + 0x79, 0x40, 0x26, 0x89, 0xba, 0xca, 0x8a, 0x9c, 0x07, 0x77, 0x7f, 0x46, 0xac, 0xf8, 0xb5, 0x39, + 0xe6, 0x63, 0x6e, 0xcc, 0x40, 0x5b, 0x79, 0xf4, 0xc5, 0x3f, 0x8d, 0xab, 0xae, 0x12, 0x22, 0x83, + 0x09, 0x4f, 0x99, 0xca, 0xbe, 0x79, 0xf5, 0xc1, 0x7f, 0x54, 0xcf, 0x82, 0xb7, 0x56, 0x76, 0x8a, + 0xf7, 0xb5, 0x01, 0x9d, 0x7d, 0x41, 0x22, 0x45, 0x42, 0xf2, 0x39, 0x25, 0x52, 0xa1, 0x2e, 0x34, + 0xe8, 0x08, 0x5b, 0x3d, 0xab, 0x7f, 0x6f, 0xcf, 0x9e, 0xfe, 0xdc, 0x6a, 0x1c,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, 0x93, 0xf3, 0xc4, 0xda, 0xc3, 0xd7, 0x37, 0xee, + 0xd2, 0x8f, 0x1b, 0x77, 0xe9, 0xcb, 0xd4, 0xb5, 0xae, 0xa7, 0xae, 0xf5, 0x7d, 0xea, 0x5a, 0xbf, + 0xa6, 0xae, 0x75, 0x66, 0x9b, 0xc6, 0xcf, 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0xd5, 0xe9, 0x01, + 0xd2, 0x5b, 0x06, 0x00, 0x00, } diff --git a/api/services/execution/execution.proto b/api/services/execution/execution.proto index 1548696..20b0856 100644 --- a/api/services/execution/execution.proto +++ b/api/services/execution/execution.proto @@ -14,6 +14,7 @@ service ContainerService { rpc Delete(DeleteRequest) returns (DeleteResponse); rpc Info(InfoRequest) returns (containerd.v1.types.Container); rpc List(ListRequest) returns (ListResponse); + rpc Kill(KillRequest) returns (google.protobuf.Empty); rpc Events(EventsRequest) returns (stream containerd.v1.types.Event); } @@ -57,5 +58,11 @@ message ListResponse { repeated containerd.v1.types.Container containers = 1; } +message KillRequest { + string id = 1 [(gogoproto.customname) = "ID"]; + uint32 signal = 2; + bool all = 3; +} + message EventsRequest { } diff --git a/container.go b/container.go index a041567..5cf9371 100644 --- a/container.go +++ b/container.go @@ -14,6 +14,8 @@ type Container interface { Start(context.Context) error // State returns the container's state State(context.Context) (State, error) + // Kill signals a container + Kill(context.Context, uint32, bool) error } type LinuxContainer interface { diff --git a/linux/container.go b/linux/container.go index 7ad5c09..021112c 100644 --- a/linux/container.go +++ b/linux/container.go @@ -70,3 +70,11 @@ func (c *Container) Resume(ctx context.Context) error { _, err := c.shim.Resume(ctx, &shim.ResumeRequest{}) return err } + +func (c *Container) Kill(ctx context.Context, signal uint32, all bool) error { + _, err := c.shim.Kill(ctx, &shim.KillRequest{ + Signal: signal, + All: all, + }) + return err +} diff --git a/services/execution/service.go b/services/execution/service.go index aa55979..5666b96 100644 --- a/services/execution/service.go +++ b/services/execution/service.go @@ -185,6 +185,17 @@ func (s *Service) List(ctx context.Context, r *api.ListRequest) (*api.ListRespon return resp, nil } +func (s *Service) Kill(ctx context.Context, r *api.KillRequest) (*google_protobuf.Empty, error) { + c, err := s.getContainer(r.ID) + if err != nil { + return nil, err + } + if err := c.Kill(ctx, r.Signal, r.All); err != nil { + return nil, err + } + return empty, nil +} + func (s *Service) Events(r *api.EventsRequest, server api.ContainerService_EventsServer) error { w := &grpcEventWriter{ server: server,