From 193abed96e06a45fead2ed86cfbb11c2a0a001a4 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Mon, 8 May 2017 20:43:30 -0700 Subject: [PATCH] content: unify provider and ingester The split between provider and ingester was a long standing division reflecting the client-side use cases. For the most part, we were differentiating these for the algorithms that operate them, but it made instantation and use of the types challenging. On the server-side, this distinction is generally less important. This change unifies these types and in the process we get a few benefits. The first is that we now completely access the content store over GRPC. This was the initial intent and we have now satisfied this goal completely. There are a few issues around listing content and getting status, but we resolve these with simple streaming and regexp filters. More can probably be done to polish this but the result is clean. Several other content-oriented methods were polished in the process of unification. We have now properly seperated out the `Abort` method to cancel ongoing or stalled ingest processes. We have also replaced the `Active` method with a single status method. The transition went extremely smoothly. Once the clients were updated to use the new methods, every thing worked as expected on the first compile. Signed-off-by: Stephen J Day --- api/services/content/content.pb.go | 1837 +++++++++++++------ api/services/content/content.proto | 77 +- api/services/execution/execution.pb.go | 2 +- api/services/images/images.pb.go | 2 +- api/services/rootfs/rootfs.pb.go | 2 +- api/services/shim/shim.pb.go | 2 +- api/types/container/container.pb.go | 2 +- api/types/descriptor/descriptor.pb.go | 2 +- api/types/mount/mount.pb.go | 2 +- cmd/containerd/main.go | 6 +- cmd/ctr/run.go | 8 +- cmd/ctr/utils.go | 4 +- cmd/dist/active.go | 11 +- cmd/dist/common.go | 11 +- cmd/dist/edit.go | 9 +- cmd/dist/fetch.go | 9 +- cmd/dist/get.go | 6 +- cmd/dist/images.go | 8 +- cmd/dist/ingest.go | 14 +- cmd/dist/list.go | 15 +- cmd/dist/pull.go | 29 +- cmd/dist/rootfs.go | 10 +- content/content.go | 54 +- content/content_test.go | 22 +- content/store.go | 137 +- content/writer.go | 2 +- plugin/plugin.go | 2 +- services/content/helpers.go | 11 + services/content/{provider.go => reader.go} | 26 - services/content/service.go | 108 +- services/content/store.go | 155 ++ services/content/{ingester.go => writer.go} | 47 - services/rootfs/service.go | 4 +- snapshot/storage/proto/record.pb.go | 2 +- 34 files changed, 1779 insertions(+), 859 deletions(-) rename services/content/{provider.go => reader.go} (60%) create mode 100644 services/content/store.go rename services/content/{ingester.go => writer.go} (70%) diff --git a/api/services/content/content.pb.go b/api/services/content/content.pb.go index 0346b12a8..f0dedda52 100644 --- a/api/services/content/content.pb.go +++ b/api/services/content/content.pb.go @@ -9,15 +9,20 @@ github.com/containerd/containerd/api/services/content/content.proto It has these top-level messages: + Info InfoRequest InfoResponse + ListContentRequest + ListContentResponse DeleteContentRequest ReadRequest ReadResponse + StatusRequest + Status + StatusResponse WriteRequest WriteResponse - StatusRequest - StatusResponse + AbortRequest */ package content @@ -77,24 +82,17 @@ const ( // // This action will always terminate the write. WriteActionCommit WriteAction = 2 - // WriteActionAbort will release any resources associated with the write - // and free up the ref for a completely new set of writes. - // - // This action will always terminate the write. - WriteActionAbort WriteAction = -1 ) var WriteAction_name = map[int32]string{ - 0: "STAT", - 1: "WRITE", - 2: "COMMIT", - -1: "ABORT", + 0: "STAT", + 1: "WRITE", + 2: "COMMIT", } var WriteAction_value = map[string]int32{ "STAT": 0, "WRITE": 1, "COMMIT": 2, - "ABORT": -1, } func (x WriteAction) String() string { @@ -102,15 +100,7 @@ func (x WriteAction) String() string { } func (WriteAction) EnumDescriptor() ([]byte, []int) { return fileDescriptorContent, []int{0} } -type InfoRequest struct { - Digest github_com_opencontainers_go_digest.Digest `protobuf:"bytes,1,opt,name=digest,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"digest"` -} - -func (m *InfoRequest) Reset() { *m = InfoRequest{} } -func (*InfoRequest) ProtoMessage() {} -func (*InfoRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{0} } - -type InfoResponse struct { +type Info struct { // Digest is the hash identity of the blob. Digest github_com_opencontainers_go_digest.Digest `protobuf:"bytes,1,opt,name=digest,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"digest"` // Size is the total number of bytes in the blob. @@ -119,9 +109,40 @@ type InfoResponse struct { CommittedAt time.Time `protobuf:"bytes,3,opt,name=committed_at,json=committedAt,stdtime" json:"committed_at"` } +func (m *Info) Reset() { *m = Info{} } +func (*Info) ProtoMessage() {} +func (*Info) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{0} } + +type InfoRequest struct { + Digest github_com_opencontainers_go_digest.Digest `protobuf:"bytes,1,opt,name=digest,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"digest"` +} + +func (m *InfoRequest) Reset() { *m = InfoRequest{} } +func (*InfoRequest) ProtoMessage() {} +func (*InfoRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{1} } + +type InfoResponse struct { + Info Info `protobuf:"bytes,1,opt,name=info" json:"info"` +} + func (m *InfoResponse) Reset() { *m = InfoResponse{} } func (*InfoResponse) ProtoMessage() {} -func (*InfoResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{1} } +func (*InfoResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{2} } + +type ListContentRequest struct { +} + +func (m *ListContentRequest) Reset() { *m = ListContentRequest{} } +func (*ListContentRequest) ProtoMessage() {} +func (*ListContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{3} } + +type ListContentResponse struct { + Info []Info `protobuf:"bytes,1,rep,name=info" json:"info"` +} + +func (m *ListContentResponse) Reset() { *m = ListContentResponse{} } +func (*ListContentResponse) ProtoMessage() {} +func (*ListContentResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{4} } type DeleteContentRequest struct { // Digest specifies which content to delete. @@ -130,7 +151,7 @@ type DeleteContentRequest struct { func (m *DeleteContentRequest) Reset() { *m = DeleteContentRequest{} } func (*DeleteContentRequest) ProtoMessage() {} -func (*DeleteContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{2} } +func (*DeleteContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{5} } // ReadRequest defines the fields that make up a request to read a portion of // data from a stored object. @@ -148,7 +169,7 @@ type ReadRequest struct { func (m *ReadRequest) Reset() { *m = ReadRequest{} } func (*ReadRequest) ProtoMessage() {} -func (*ReadRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{3} } +func (*ReadRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{6} } // ReadResponse carries byte data for a read request. type ReadResponse struct { @@ -158,7 +179,36 @@ type ReadResponse struct { func (m *ReadResponse) Reset() { *m = ReadResponse{} } func (*ReadResponse) ProtoMessage() {} -func (*ReadResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{4} } +func (*ReadResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{7} } + +type StatusRequest struct { + Regexp string `protobuf:"bytes,1,opt,name=regexp,proto3" json:"regexp,omitempty"` +} + +func (m *StatusRequest) Reset() { *m = StatusRequest{} } +func (*StatusRequest) ProtoMessage() {} +func (*StatusRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{8} } + +type Status struct { + StartedAt time.Time `protobuf:"bytes,1,opt,name=started_at,json=startedAt,stdtime" json:"started_at"` + UpdatedAt time.Time `protobuf:"bytes,2,opt,name=updated_at,json=updatedAt,stdtime" json:"updated_at"` + Ref string `protobuf:"bytes,3,opt,name=ref,proto3" json:"ref,omitempty"` + Offset int64 `protobuf:"varint,4,opt,name=offset,proto3" json:"offset,omitempty"` + Total int64 `protobuf:"varint,5,opt,name=total,proto3" json:"total,omitempty"` + Expected github_com_opencontainers_go_digest.Digest `protobuf:"bytes,6,opt,name=expected,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"expected"` +} + +func (m *Status) Reset() { *m = Status{} } +func (*Status) ProtoMessage() {} +func (*Status) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{9} } + +type StatusResponse struct { + Statuses []Status `protobuf:"bytes,1,rep,name=statuses" json:"statuses"` +} + +func (m *StatusResponse) Reset() { *m = StatusResponse{} } +func (*StatusResponse) ProtoMessage() {} +func (*StatusResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{10} } // WriteRequest writes data to the request ref at offset. type WriteRequest struct { @@ -215,7 +265,7 @@ type WriteRequest struct { func (m *WriteRequest) Reset() { *m = WriteRequest{} } func (*WriteRequest) ProtoMessage() {} -func (*WriteRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{5} } +func (*WriteRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{11} } // WriteResponse is returned on the culmination of a write call. type WriteResponse struct { @@ -243,46 +293,37 @@ type WriteResponse struct { Total int64 `protobuf:"varint,5,opt,name=total,proto3" json:"total,omitempty"` // Digest, if present, includes the digest up to the currently committed // bytes. If action is commit, this field will be set. It is implementation - // defined if this is set for other actions, except abort. On abort, this - // will be empty. + // defined if this is set for other actions. Digest github_com_opencontainers_go_digest.Digest `protobuf:"bytes,6,opt,name=digest,proto3,customtype=github.com/opencontainers/go-digest.Digest" json:"digest"` } func (m *WriteResponse) Reset() { *m = WriteResponse{} } func (*WriteResponse) ProtoMessage() {} -func (*WriteResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{6} } +func (*WriteResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{12} } -type StatusRequest struct { - Refs []string `protobuf:"bytes,1,rep,name=refs" json:"refs,omitempty"` - Prefix []string `protobuf:"bytes,2,rep,name=prefix" json:"prefix,omitempty"` +type AbortRequest struct { + Ref string `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` } -func (m *StatusRequest) Reset() { *m = StatusRequest{} } -func (*StatusRequest) ProtoMessage() {} -func (*StatusRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{7} } - -type StatusResponse struct { - StartedAt time.Time `protobuf:"bytes,1,opt,name=started_at,json=startedAt,stdtime" json:"started_at"` - UpdatedAt time.Time `protobuf:"bytes,2,opt,name=updated_at,json=updatedAt,stdtime" json:"updated_at"` - Ref string `protobuf:"bytes,3,opt,name=ref,proto3" json:"ref,omitempty"` - Offset int64 `protobuf:"varint,4,opt,name=offset,proto3" json:"offset,omitempty"` - Total int64 `protobuf:"varint,5,opt,name=total,proto3" json:"total,omitempty"` -} - -func (m *StatusResponse) Reset() { *m = StatusResponse{} } -func (*StatusResponse) ProtoMessage() {} -func (*StatusResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{8} } +func (m *AbortRequest) Reset() { *m = AbortRequest{} } +func (*AbortRequest) ProtoMessage() {} +func (*AbortRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{13} } func init() { + proto.RegisterType((*Info)(nil), "containerd.v1.Info") proto.RegisterType((*InfoRequest)(nil), "containerd.v1.InfoRequest") proto.RegisterType((*InfoResponse)(nil), "containerd.v1.InfoResponse") + proto.RegisterType((*ListContentRequest)(nil), "containerd.v1.ListContentRequest") + proto.RegisterType((*ListContentResponse)(nil), "containerd.v1.ListContentResponse") proto.RegisterType((*DeleteContentRequest)(nil), "containerd.v1.DeleteContentRequest") proto.RegisterType((*ReadRequest)(nil), "containerd.v1.ReadRequest") proto.RegisterType((*ReadResponse)(nil), "containerd.v1.ReadResponse") + proto.RegisterType((*StatusRequest)(nil), "containerd.v1.StatusRequest") + proto.RegisterType((*Status)(nil), "containerd.v1.Status") + proto.RegisterType((*StatusResponse)(nil), "containerd.v1.StatusResponse") proto.RegisterType((*WriteRequest)(nil), "containerd.v1.WriteRequest") proto.RegisterType((*WriteResponse)(nil), "containerd.v1.WriteResponse") - proto.RegisterType((*StatusRequest)(nil), "containerd.v1.StatusRequest") - proto.RegisterType((*StatusResponse)(nil), "containerd.v1.StatusResponse") + proto.RegisterType((*AbortRequest)(nil), "containerd.v1.AbortRequest") proto.RegisterEnum("containerd.v1.WriteAction", WriteAction_name, WriteAction_value) } @@ -302,6 +343,13 @@ type ContentClient interface { // This call can be used for getting the size of content and checking for // existence. Info(ctx context.Context, in *InfoRequest, opts ...grpc.CallOption) (*InfoResponse, error) + // List streams the entire set of content as Info objects and closes the + // stream. + // + // Typically, this will yield a large response, chunked into messages. + // Clients should make provisions to ensure they can't handle the entire + // data set. + List(ctx context.Context, in *ListContentRequest, opts ...grpc.CallOption) (Content_ListClient, error) // Delete will delete the referenced object. Delete(ctx context.Context, in *DeleteContentRequest, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) // Read allows one to read an object based on the offset into the content. @@ -311,9 +359,10 @@ type ContentClient interface { // Status returns the status of ongoing object ingestions, started via // Write. // - // For active ingestions, the status will be streamed until the client - // closes the connection or all matched ingestions are committed. - Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (Content_StatusClient, error) + // Only those matching the regular expression will be provided in the + // response. If the provided regular expression is empty, all ingestions + // will be provided. + Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) // Write begins or resumes writes to a resource identified by a unique ref. // Only one active stream may exist at a time for each ref. // @@ -331,6 +380,9 @@ type ContentClient interface { // When completed, the commit flag should be set to true. If expected size // or digest is set, the content will be validated against those values. Write(ctx context.Context, opts ...grpc.CallOption) (Content_WriteClient, error) + // Abort cancels the ongoing write named in the request. Any resources + // associated with the write will be collected. + Abort(ctx context.Context, in *AbortRequest, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) } type contentClient struct { @@ -350,6 +402,38 @@ func (c *contentClient) Info(ctx context.Context, in *InfoRequest, opts ...grpc. return out, nil } +func (c *contentClient) List(ctx context.Context, in *ListContentRequest, opts ...grpc.CallOption) (Content_ListClient, error) { + stream, err := grpc.NewClientStream(ctx, &_Content_serviceDesc.Streams[0], c.cc, "/containerd.v1.Content/List", opts...) + if err != nil { + return nil, err + } + x := &contentListClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type Content_ListClient interface { + Recv() (*ListContentResponse, error) + grpc.ClientStream +} + +type contentListClient struct { + grpc.ClientStream +} + +func (x *contentListClient) Recv() (*ListContentResponse, error) { + m := new(ListContentResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + func (c *contentClient) Delete(ctx context.Context, in *DeleteContentRequest, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { out := new(google_protobuf2.Empty) err := grpc.Invoke(ctx, "/containerd.v1.Content/Delete", in, out, c.cc, opts...) @@ -360,7 +444,7 @@ func (c *contentClient) Delete(ctx context.Context, in *DeleteContentRequest, op } func (c *contentClient) Read(ctx context.Context, in *ReadRequest, opts ...grpc.CallOption) (Content_ReadClient, error) { - stream, err := grpc.NewClientStream(ctx, &_Content_serviceDesc.Streams[0], c.cc, "/containerd.v1.Content/Read", opts...) + stream, err := grpc.NewClientStream(ctx, &_Content_serviceDesc.Streams[1], c.cc, "/containerd.v1.Content/Read", opts...) if err != nil { return nil, err } @@ -391,36 +475,13 @@ func (x *contentReadClient) Recv() (*ReadResponse, error) { return m, nil } -func (c *contentClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (Content_StatusClient, error) { - stream, err := grpc.NewClientStream(ctx, &_Content_serviceDesc.Streams[1], c.cc, "/containerd.v1.Content/Status", opts...) +func (c *contentClient) Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error) { + out := new(StatusResponse) + err := grpc.Invoke(ctx, "/containerd.v1.Content/Status", in, out, c.cc, opts...) if err != nil { return nil, err } - x := &contentStatusClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type Content_StatusClient interface { - Recv() (*StatusResponse, error) - grpc.ClientStream -} - -type contentStatusClient struct { - grpc.ClientStream -} - -func (x *contentStatusClient) Recv() (*StatusResponse, error) { - m := new(StatusResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil + return out, nil } func (c *contentClient) Write(ctx context.Context, opts ...grpc.CallOption) (Content_WriteClient, error) { @@ -454,6 +515,15 @@ func (x *contentWriteClient) Recv() (*WriteResponse, error) { return m, nil } +func (c *contentClient) Abort(ctx context.Context, in *AbortRequest, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { + out := new(google_protobuf2.Empty) + err := grpc.Invoke(ctx, "/containerd.v1.Content/Abort", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // Server API for Content service type ContentServer interface { @@ -462,6 +532,13 @@ type ContentServer interface { // This call can be used for getting the size of content and checking for // existence. Info(context.Context, *InfoRequest) (*InfoResponse, error) + // List streams the entire set of content as Info objects and closes the + // stream. + // + // Typically, this will yield a large response, chunked into messages. + // Clients should make provisions to ensure they can't handle the entire + // data set. + List(*ListContentRequest, Content_ListServer) error // Delete will delete the referenced object. Delete(context.Context, *DeleteContentRequest) (*google_protobuf2.Empty, error) // Read allows one to read an object based on the offset into the content. @@ -471,9 +548,10 @@ type ContentServer interface { // Status returns the status of ongoing object ingestions, started via // Write. // - // For active ingestions, the status will be streamed until the client - // closes the connection or all matched ingestions are committed. - Status(*StatusRequest, Content_StatusServer) error + // Only those matching the regular expression will be provided in the + // response. If the provided regular expression is empty, all ingestions + // will be provided. + Status(context.Context, *StatusRequest) (*StatusResponse, error) // Write begins or resumes writes to a resource identified by a unique ref. // Only one active stream may exist at a time for each ref. // @@ -491,6 +569,9 @@ type ContentServer interface { // When completed, the commit flag should be set to true. If expected size // or digest is set, the content will be validated against those values. Write(Content_WriteServer) error + // Abort cancels the ongoing write named in the request. Any resources + // associated with the write will be collected. + Abort(context.Context, *AbortRequest) (*google_protobuf2.Empty, error) } func RegisterContentServer(s *grpc.Server, srv ContentServer) { @@ -515,6 +596,27 @@ func _Content_Info_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Content_List_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(ListContentRequest) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(ContentServer).List(m, &contentListServer{stream}) +} + +type Content_ListServer interface { + Send(*ListContentResponse) error + grpc.ServerStream +} + +type contentListServer struct { + grpc.ServerStream +} + +func (x *contentListServer) Send(m *ListContentResponse) error { + return x.ServerStream.SendMsg(m) +} + func _Content_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(DeleteContentRequest) if err := dec(in); err != nil { @@ -554,25 +656,22 @@ func (x *contentReadServer) Send(m *ReadResponse) error { return x.ServerStream.SendMsg(m) } -func _Content_Status_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(StatusRequest) - if err := stream.RecvMsg(m); err != nil { - return err +func _Content_Status_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StatusRequest) + if err := dec(in); err != nil { + return nil, err } - return srv.(ContentServer).Status(m, &contentStatusServer{stream}) -} - -type Content_StatusServer interface { - Send(*StatusResponse) error - grpc.ServerStream -} - -type contentStatusServer struct { - grpc.ServerStream -} - -func (x *contentStatusServer) Send(m *StatusResponse) error { - return x.ServerStream.SendMsg(m) + if interceptor == nil { + return srv.(ContentServer).Status(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.Content/Status", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ContentServer).Status(ctx, req.(*StatusRequest)) + } + return interceptor(ctx, in, info, handler) } func _Content_Write_Handler(srv interface{}, stream grpc.ServerStream) error { @@ -601,6 +700,24 @@ func (x *contentWriteServer) Recv() (*WriteRequest, error) { return m, nil } +func _Content_Abort_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AbortRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ContentServer).Abort(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/containerd.v1.Content/Abort", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ContentServer).Abort(ctx, req.(*AbortRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Content_serviceDesc = grpc.ServiceDesc{ ServiceName: "containerd.v1.Content", HandlerType: (*ContentServer)(nil), @@ -613,16 +730,24 @@ var _Content_serviceDesc = grpc.ServiceDesc{ MethodName: "Delete", Handler: _Content_Delete_Handler, }, + { + MethodName: "Status", + Handler: _Content_Status_Handler, + }, + { + MethodName: "Abort", + Handler: _Content_Abort_Handler, + }, }, Streams: []grpc.StreamDesc{ { - StreamName: "Read", - Handler: _Content_Read_Handler, + StreamName: "List", + Handler: _Content_List_Handler, ServerStreams: true, }, { - StreamName: "Status", - Handler: _Content_Status_Handler, + StreamName: "Read", + Handler: _Content_Read_Handler, ServerStreams: true, }, { @@ -635,6 +760,43 @@ var _Content_serviceDesc = grpc.ServiceDesc{ Metadata: "github.com/containerd/containerd/api/services/content/content.proto", } +func (m *Info) 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 *Info) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Digest) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintContent(dAtA, i, uint64(len(m.Digest))) + i += copy(dAtA[i:], m.Digest) + } + if m.Size_ != 0 { + dAtA[i] = 0x10 + i++ + i = encodeVarintContent(dAtA, i, uint64(m.Size_)) + } + dAtA[i] = 0x1a + i++ + i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.CommittedAt))) + n1, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CommittedAt, dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + return i, nil +} + func (m *InfoRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -674,25 +836,62 @@ func (m *InfoResponse) MarshalTo(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Digest) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintContent(dAtA, i, uint64(len(m.Digest))) - i += copy(dAtA[i:], m.Digest) - } - if m.Size_ != 0 { - dAtA[i] = 0x10 - i++ - i = encodeVarintContent(dAtA, i, uint64(m.Size_)) - } - dAtA[i] = 0x1a + dAtA[i] = 0xa i++ - i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.CommittedAt))) - n1, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CommittedAt, dAtA[i:]) + i = encodeVarintContent(dAtA, i, uint64(m.Info.Size())) + n2, err := m.Info.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n1 + i += n2 + return i, nil +} + +func (m *ListContentRequest) 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 *ListContentRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + return i, nil +} + +func (m *ListContentResponse) 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 *ListContentResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Info) > 0 { + for _, msg := range m.Info { + dAtA[i] = 0xa + i++ + i = encodeVarintContent(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } return i, nil } @@ -783,6 +982,116 @@ func (m *ReadResponse) MarshalTo(dAtA []byte) (int, error) { return i, nil } +func (m *StatusRequest) 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 *StatusRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Regexp) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintContent(dAtA, i, uint64(len(m.Regexp))) + i += copy(dAtA[i:], m.Regexp) + } + return i, nil +} + +func (m *Status) 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 *Status) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + dAtA[i] = 0xa + i++ + i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.StartedAt))) + n3, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartedAt, dAtA[i:]) + if err != nil { + return 0, err + } + i += n3 + dAtA[i] = 0x12 + i++ + i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt))) + n4, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i:]) + if err != nil { + return 0, err + } + i += n4 + if len(m.Ref) > 0 { + dAtA[i] = 0x1a + i++ + i = encodeVarintContent(dAtA, i, uint64(len(m.Ref))) + i += copy(dAtA[i:], m.Ref) + } + if m.Offset != 0 { + dAtA[i] = 0x20 + i++ + i = encodeVarintContent(dAtA, i, uint64(m.Offset)) + } + if m.Total != 0 { + dAtA[i] = 0x28 + i++ + i = encodeVarintContent(dAtA, i, uint64(m.Total)) + } + if len(m.Expected) > 0 { + dAtA[i] = 0x32 + i++ + i = encodeVarintContent(dAtA, i, uint64(len(m.Expected))) + i += copy(dAtA[i:], m.Expected) + } + return i, nil +} + +func (m *StatusResponse) 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 *StatusResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Statuses) > 0 { + for _, msg := range m.Statuses { + dAtA[i] = 0xa + i++ + i = encodeVarintContent(dAtA, i, uint64(msg.Size())) + n, err := msg.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n + } + } + return i, nil +} + func (m *WriteRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -857,19 +1166,19 @@ func (m *WriteResponse) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.StartedAt))) - n2, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartedAt, dAtA[i:]) + n5, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartedAt, dAtA[i:]) if err != nil { return 0, err } - i += n2 + i += n5 dAtA[i] = 0x1a i++ i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt))) - n3, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i:]) + n6, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i:]) if err != nil { return 0, err } - i += n3 + i += n6 if m.Offset != 0 { dAtA[i] = 0x20 i++ @@ -889,7 +1198,7 @@ func (m *WriteResponse) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *StatusRequest) Marshal() (dAtA []byte, err error) { +func (m *AbortRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -899,91 +1208,17 @@ func (m *StatusRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *StatusRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *AbortRequest) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int _ = l - if len(m.Refs) > 0 { - for _, s := range m.Refs { - dAtA[i] = 0xa - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } - } - if len(m.Prefix) > 0 { - for _, s := range m.Prefix { - dAtA[i] = 0x12 - i++ - l = len(s) - for l >= 1<<7 { - dAtA[i] = uint8(uint64(l)&0x7f | 0x80) - l >>= 7 - i++ - } - dAtA[i] = uint8(l) - i++ - i += copy(dAtA[i:], s) - } - } - return i, nil -} - -func (m *StatusResponse) 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 *StatusResponse) MarshalTo(dAtA []byte) (int, error) { - var i int - _ = i - var l int - _ = l - dAtA[i] = 0xa - i++ - i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.StartedAt))) - n4, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartedAt, dAtA[i:]) - if err != nil { - return 0, err - } - i += n4 - dAtA[i] = 0x12 - i++ - i = encodeVarintContent(dAtA, i, uint64(github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt))) - n5, err := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdatedAt, dAtA[i:]) - if err != nil { - return 0, err - } - i += n5 if len(m.Ref) > 0 { - dAtA[i] = 0x1a + dAtA[i] = 0xa i++ i = encodeVarintContent(dAtA, i, uint64(len(m.Ref))) i += copy(dAtA[i:], m.Ref) } - if m.Offset != 0 { - dAtA[i] = 0x20 - i++ - i = encodeVarintContent(dAtA, i, uint64(m.Offset)) - } - if m.Total != 0 { - dAtA[i] = 0x28 - i++ - i = encodeVarintContent(dAtA, i, uint64(m.Total)) - } return i, nil } @@ -1014,6 +1249,21 @@ func encodeVarintContent(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return offset + 1 } +func (m *Info) Size() (n int) { + var l int + _ = l + l = len(m.Digest) + if l > 0 { + n += 1 + l + sovContent(uint64(l)) + } + if m.Size_ != 0 { + n += 1 + sovContent(uint64(m.Size_)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CommittedAt) + n += 1 + l + sovContent(uint64(l)) + return n +} + func (m *InfoRequest) Size() (n int) { var l int _ = l @@ -1027,18 +1277,29 @@ func (m *InfoRequest) Size() (n int) { func (m *InfoResponse) Size() (n int) { var l int _ = l - l = len(m.Digest) - if l > 0 { - n += 1 + l + sovContent(uint64(l)) - } - if m.Size_ != 0 { - n += 1 + sovContent(uint64(m.Size_)) - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CommittedAt) + l = m.Info.Size() n += 1 + l + sovContent(uint64(l)) return n } +func (m *ListContentRequest) Size() (n int) { + var l int + _ = l + return n +} + +func (m *ListContentResponse) Size() (n int) { + var l int + _ = l + if len(m.Info) > 0 { + for _, e := range m.Info { + l = e.Size() + n += 1 + l + sovContent(uint64(l)) + } + } + return n +} + func (m *DeleteContentRequest) Size() (n int) { var l int _ = l @@ -1078,6 +1339,52 @@ func (m *ReadResponse) Size() (n int) { return n } +func (m *StatusRequest) Size() (n int) { + var l int + _ = l + l = len(m.Regexp) + if l > 0 { + n += 1 + l + sovContent(uint64(l)) + } + return n +} + +func (m *Status) Size() (n int) { + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartedAt) + n += 1 + l + sovContent(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt) + n += 1 + l + sovContent(uint64(l)) + l = len(m.Ref) + if l > 0 { + n += 1 + l + sovContent(uint64(l)) + } + if m.Offset != 0 { + n += 1 + sovContent(uint64(m.Offset)) + } + if m.Total != 0 { + n += 1 + sovContent(uint64(m.Total)) + } + l = len(m.Expected) + if l > 0 { + n += 1 + l + sovContent(uint64(l)) + } + return n +} + +func (m *StatusResponse) Size() (n int) { + var l int + _ = l + if len(m.Statuses) > 0 { + for _, e := range m.Statuses { + l = e.Size() + n += 1 + l + sovContent(uint64(l)) + } + } + return n +} + func (m *WriteRequest) Size() (n int) { var l int _ = l @@ -1128,41 +1435,13 @@ func (m *WriteResponse) Size() (n int) { return n } -func (m *StatusRequest) Size() (n int) { +func (m *AbortRequest) Size() (n int) { var l int _ = l - if len(m.Refs) > 0 { - for _, s := range m.Refs { - l = len(s) - n += 1 + l + sovContent(uint64(l)) - } - } - if len(m.Prefix) > 0 { - for _, s := range m.Prefix { - l = len(s) - n += 1 + l + sovContent(uint64(l)) - } - } - return n -} - -func (m *StatusResponse) Size() (n int) { - var l int - _ = l - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartedAt) - n += 1 + l + sovContent(uint64(l)) - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdatedAt) - n += 1 + l + sovContent(uint64(l)) l = len(m.Ref) if l > 0 { n += 1 + l + sovContent(uint64(l)) } - if m.Offset != 0 { - n += 1 + sovContent(uint64(m.Offset)) - } - if m.Total != 0 { - n += 1 + sovContent(uint64(m.Total)) - } return n } @@ -1179,6 +1458,18 @@ func sovContent(x uint64) (n int) { func sozContent(x uint64) (n int) { return sovContent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (this *Info) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Info{`, + `Digest:` + fmt.Sprintf("%v", this.Digest) + `,`, + `Size_:` + fmt.Sprintf("%v", this.Size_) + `,`, + `CommittedAt:` + strings.Replace(strings.Replace(this.CommittedAt.String(), "Timestamp", "google_protobuf1.Timestamp", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} func (this *InfoRequest) String() string { if this == nil { return "nil" @@ -1194,9 +1485,26 @@ func (this *InfoResponse) String() string { return "nil" } s := strings.Join([]string{`&InfoResponse{`, - `Digest:` + fmt.Sprintf("%v", this.Digest) + `,`, - `Size_:` + fmt.Sprintf("%v", this.Size_) + `,`, - `CommittedAt:` + strings.Replace(strings.Replace(this.CommittedAt.String(), "Timestamp", "google_protobuf1.Timestamp", 1), `&`, ``, 1) + `,`, + `Info:` + strings.Replace(strings.Replace(this.Info.String(), "Info", "Info", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} +func (this *ListContentRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ListContentRequest{`, + `}`, + }, "") + return s +} +func (this *ListContentResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ListContentResponse{`, + `Info:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Info), "Info", "Info", 1), `&`, ``, 1) + `,`, `}`, }, "") return s @@ -1234,6 +1542,41 @@ func (this *ReadResponse) String() string { }, "") return s } +func (this *StatusRequest) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&StatusRequest{`, + `Regexp:` + fmt.Sprintf("%v", this.Regexp) + `,`, + `}`, + }, "") + return s +} +func (this *Status) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&Status{`, + `StartedAt:` + strings.Replace(strings.Replace(this.StartedAt.String(), "Timestamp", "google_protobuf1.Timestamp", 1), `&`, ``, 1) + `,`, + `UpdatedAt:` + strings.Replace(strings.Replace(this.UpdatedAt.String(), "Timestamp", "google_protobuf1.Timestamp", 1), `&`, ``, 1) + `,`, + `Ref:` + fmt.Sprintf("%v", this.Ref) + `,`, + `Offset:` + fmt.Sprintf("%v", this.Offset) + `,`, + `Total:` + fmt.Sprintf("%v", this.Total) + `,`, + `Expected:` + fmt.Sprintf("%v", this.Expected) + `,`, + `}`, + }, "") + return s +} +func (this *StatusResponse) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&StatusResponse{`, + `Statuses:` + strings.Replace(strings.Replace(fmt.Sprintf("%v", this.Statuses), "Status", "Status", 1), `&`, ``, 1) + `,`, + `}`, + }, "") + return s +} func (this *WriteRequest) String() string { if this == nil { return "nil" @@ -1264,27 +1607,12 @@ func (this *WriteResponse) String() string { }, "") return s } -func (this *StatusRequest) String() string { +func (this *AbortRequest) String() string { if this == nil { return "nil" } - s := strings.Join([]string{`&StatusRequest{`, - `Refs:` + fmt.Sprintf("%v", this.Refs) + `,`, - `Prefix:` + fmt.Sprintf("%v", this.Prefix) + `,`, - `}`, - }, "") - return s -} -func (this *StatusResponse) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&StatusResponse{`, - `StartedAt:` + strings.Replace(strings.Replace(this.StartedAt.String(), "Timestamp", "google_protobuf1.Timestamp", 1), `&`, ``, 1) + `,`, - `UpdatedAt:` + strings.Replace(strings.Replace(this.UpdatedAt.String(), "Timestamp", "google_protobuf1.Timestamp", 1), `&`, ``, 1) + `,`, + s := strings.Join([]string{`&AbortRequest{`, `Ref:` + fmt.Sprintf("%v", this.Ref) + `,`, - `Offset:` + fmt.Sprintf("%v", this.Offset) + `,`, - `Total:` + fmt.Sprintf("%v", this.Total) + `,`, `}`, }, "") return s @@ -1297,6 +1625,134 @@ func valueToStringContent(v interface{}) string { pv := reflect.Indirect(rv).Interface() return fmt.Sprintf("*%v", pv) } +func (m *Info) 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 ErrIntOverflowContent + } + 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: Info: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Info: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Digest", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + 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 ErrInvalidLengthContent + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Digest = github_com_opencontainers_go_digest.Digest(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) + } + m.Size_ = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size_ |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommittedAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthContent + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.CommittedAt, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipContent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthContent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *InfoRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1407,55 +1863,7 @@ func (m *InfoResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Digest", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowContent - } - 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 ErrInvalidLengthContent - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Digest = github_com_opencontainers_go_digest.Digest(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) - } - m.Size_ = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowContent - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Size_ |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommittedAt", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1479,7 +1887,138 @@ func (m *InfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.CommittedAt, dAtA[iNdEx:postIndex]); err != nil { + if err := m.Info.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipContent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthContent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListContentRequest) 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 ErrIntOverflowContent + } + 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: ListContentRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListContentRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipContent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthContent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListContentResponse) 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 ErrIntOverflowContent + } + 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: ListContentResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListContentResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthContent + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Info = append(m.Info, Info{}) + if err := m.Info[len(m.Info)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1800,6 +2339,372 @@ func (m *ReadResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *StatusRequest) 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 ErrIntOverflowContent + } + 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: StatusRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Regexp", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + 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 ErrInvalidLengthContent + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Regexp = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipContent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthContent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Status) 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 ErrIntOverflowContent + } + 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: Status: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Status: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartedAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthContent + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartedAt, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthContent + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.UpdatedAt, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ref", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + 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 ErrInvalidLengthContent + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ref = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType) + } + m.Offset = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Offset |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Total", wireType) + } + m.Total = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Total |= (int64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expected", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + 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 ErrInvalidLengthContent + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Expected = github_com_opencontainers_go_digest.Digest(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipContent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthContent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StatusResponse) 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 ErrIntOverflowContent + } + 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: StatusResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Statuses", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowContent + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthContent + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Statuses = append(m.Statuses, Status{}) + if err := m.Statuses[len(m.Statuses)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipContent(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthContent + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *WriteRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -2192,7 +3097,7 @@ func (m *WriteResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *StatusRequest) Unmarshal(dAtA []byte) error { +func (m *AbortRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2215,181 +3120,13 @@ func (m *StatusRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: StatusRequest: wiretype end group for non-group") + return fmt.Errorf("proto: AbortRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: StatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: AbortRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Refs", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowContent - } - 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 ErrInvalidLengthContent - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Refs = append(m.Refs, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Prefix", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowContent - } - 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 ErrInvalidLengthContent - } - postIndex := iNdEx + intStringLen - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Prefix = append(m.Prefix, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipContent(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthContent - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *StatusResponse) 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 ErrIntOverflowContent - } - 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: StatusResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: StatusResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StartedAt", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowContent - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthContent - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartedAt, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowContent - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthContent - } - postIndex := iNdEx + msglen - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.UpdatedAt, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Ref", wireType) } @@ -2418,44 +3155,6 @@ func (m *StatusResponse) Unmarshal(dAtA []byte) error { } m.Ref = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType) - } - m.Offset = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowContent - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Offset |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Total", wireType) - } - m.Total = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowContent - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Total |= (int64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipContent(dAtA[iNdEx:]) @@ -2587,53 +3286,59 @@ func init() { } var fileDescriptorContent = []byte{ - // 768 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xb4, 0x55, 0x4f, 0x6f, 0xd3, 0x4e, - 0x10, 0xcd, 0xe6, 0x8f, 0x7f, 0xcd, 0x24, 0xed, 0x2f, 0x6c, 0x43, 0x15, 0xb9, 0xad, 0x13, 0xc2, - 0x25, 0xaa, 0x84, 0x53, 0xc2, 0x0d, 0x0e, 0xc8, 0x49, 0x4b, 0x55, 0xa4, 0x52, 0xc9, 0x8d, 0x54, - 0x71, 0x42, 0x4e, 0xb2, 0x09, 0x96, 0x1a, 0xaf, 0xb1, 0x37, 0x55, 0xe1, 0xc4, 0x05, 0x09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xab, 0xd7, 0x33, 0xbf, 0x83, 0xdf, 0x24, 0x98, 0xd6, 0xa0, 0x0e, 0x93, 0x17, 0xdf, - 0xbe, 0x57, 0x22, 0x9f, 0x3f, 0x28, 0xe1, 0x09, 0x2b, 0x3f, 0xa3, 0xf0, 0x9f, 0xd8, 0x90, 0xf8, - 0x21, 0xc4, 0xbd, 0x5d, 0x8f, 0xc7, 0xff, 0x07, 0xa1, 0x8f, 0x8b, 0xbc, 0x3c, 0x35, 0x27, 0x2e, - 0x72, 0x13, 0x24, 0x7f, 0xe7, 0xe2, 0xdb, 0x63, 0x65, 0xd3, 0x56, 0xb1, 0xbc, 0x34, 0x71, 0x3d, - 0x9b, 0xde, 0x57, 0x0d, 0x6b, 0x10, 0xf7, 0xd6, 0xd9, 0xc4, 0x1c, 0xa1, 0x55, 0x3b, 0x31, 0x47, - 0x78, 0xff, 0xad, 0x23, 0xbc, 0x05, 0x92, 0x6f, 0x32, 0xbc, 0x32, 0x56, 0x38, 0xe2, 0x5c, 0x79, - 0xf5, 0x2f, 0xd9, 0x01, 0xd0, 0x23, 0x48, 0xf8, 0x57, 0xb1, 0x3c, 0x6d, 0x39, 0x04, 0x30, 0x2b, - 0xd3, 0x93, 0x3e, 0x4a, 0x09, 0xad, 0xa3, 0x6a, 0xee, 0xf4, 0x42, 0x89, 0x7c, 0xbb, 0x50, 0x22, - 0xaf, 0xfb, 0x0a, 0x3a, 0xed, 0x2b, 0xe8, 0x6b, 0x5f, 0x41, 0x3f, 0xfa, 0x0a, 0x6a, 0x48, 0x9c, - 0xfd, 0xbd, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x71, 0x48, 0x92, 0x10, 0x6e, 0x08, 0x00, 0x00, + // 860 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0xcf, 0xc4, 0x8e, 0x69, 0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x4d, 0x2b, 0x45, 0xdf, + 0x5d, 0x53, 0xc8, 0x41, 0xfc, 0x0f, 0x03, 0xee, 0x80, 0x1a, 0x8f, 0xe5, 0xb5, 0xc4, 0x32, 0x2b, + 0x63, 0x2d, 0xb1, 0xec, 0x1c, 0x17, 0x91, 0xc8, 0x99, 0xfb, 0x68, 0xe3, 0xd4, 0x48, 0x68, 0x1e, + 0x5f, 0x63, 0x95, 0x15, 0xfa, 0x00, 0x0a, 0xa2, 0x5f, 0x7b, 0x9b, 0xfe, 0x92, 0x12, 0x92, 0x47, + 0x9b, 0x8d, 0x82, 0xa3, 0x89, 0x9e, 0x23, 0xfc, 0x2e, 0x14, 0xb8, 0xc0, 0xd6, 0x78, 0xb2, 0xb2, + 0xbb, 0xae, 0x1e, 0xdd, 0xda, 0xc5, 0x95, 0x91, 0xfb, 0xed, 0xca, 0xc8, 0x7d, 0x3d, 0x37, 0xd0, + 0xc5, 0xdc, 0x40, 0xbf, 0xce, 0x0d, 0xf4, 0xe7, 0xdc, 0x40, 0x43, 0x8d, 0x23, 0xdf, 0xfa, 0x27, + 0x00, 0x00, 0xff, 0xff, 0xbc, 0x66, 0xb9, 0xa0, 0x05, 0x0a, 0x00, 0x00, } diff --git a/api/services/content/content.proto b/api/services/content/content.proto index f8f1d4c46..dd250c830 100644 --- a/api/services/content/content.proto +++ b/api/services/content/content.proto @@ -14,6 +14,14 @@ service Content { // existence. rpc Info(InfoRequest) returns (InfoResponse); + // List streams the entire set of content as Info objects and closes the + // stream. + // + // Typically, this will yield a large response, chunked into messages. + // Clients should make provisions to ensure they can handle the entire data + // set. + rpc List(ListContentRequest) returns (stream ListContentResponse); + // Delete will delete the referenced object. rpc Delete(DeleteContentRequest) returns (google.protobuf.Empty); @@ -25,9 +33,10 @@ service Content { // Status returns the status of ongoing object ingestions, started via // Write. // - // For active ingestions, the status will be streamed until the client - // closes the connection or all matched ingestions are committed. - rpc Status(StatusRequest) returns (stream StatusResponse); + // Only those matching the regular expression will be provided in the + // response. If the provided regular expression is empty, all ingestions + // will be provided. + rpc Status(StatusRequest) returns (StatusResponse); // Write begins or resumes writes to a resource identified by a unique ref. // Only one active stream may exist at a time for each ref. @@ -46,13 +55,13 @@ service Content { // When completed, the commit flag should be set to true. If expected size // or digest is set, the content will be validated against those values. rpc Write(stream WriteRequest) returns (stream WriteResponse); + + // Abort cancels the ongoing write named in the request. Any resources + // associated with the write will be collected. + rpc Abort(AbortRequest) returns (google.protobuf.Empty); } -message InfoRequest { - string digest = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false]; -} - -message InfoResponse { +message Info { // Digest is the hash identity of the blob. string digest = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false]; @@ -63,6 +72,20 @@ message InfoResponse { google.protobuf.Timestamp committed_at = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; } +message InfoRequest { + string digest = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false]; +} + +message InfoResponse { + Info info = 1 [(gogoproto.nullable) = false]; +} + +message ListContentRequest {} + +message ListContentResponse { + repeated Info info = 1 [(gogoproto.nullable) = false]; +} + message DeleteContentRequest { // Digest specifies which content to delete. string digest = 1 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false]; @@ -90,6 +113,22 @@ message ReadResponse { bytes data = 2; // actual data } +message StatusRequest { + string regexp = 1; +} + +message Status { + google.protobuf.Timestamp started_at = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + google.protobuf.Timestamp updated_at = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + string ref = 3; + int64 offset = 4; + int64 total = 5; + string expected = 6 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false]; +} + +message StatusResponse { + repeated Status statuses = 1 [(gogoproto.nullable) = false]; +} // WriteAction defines the behavior of a WriteRequest. enum WriteAction { @@ -116,12 +155,6 @@ enum WriteAction { // // This action will always terminate the write. COMMIT = 2 [(gogoproto.enumvalue_customname) = "WriteActionCommit"]; - - // WriteActionAbort will release any resources associated with the write - // and free up the ref for a completely new set of writes. - // - // This action will always terminate the write. - ABORT = -1 [(gogoproto.enumvalue_customname) = "WriteActionAbort"]; } // WriteRequest writes data to the request ref at offset. @@ -213,20 +246,10 @@ message WriteResponse { // Digest, if present, includes the digest up to the currently committed // bytes. If action is commit, this field will be set. It is implementation - // defined if this is set for other actions, except abort. On abort, this - // will be empty. + // defined if this is set for other actions. string digest = 6 [(gogoproto.customtype) = "github.com/opencontainers/go-digest.Digest", (gogoproto.nullable) = false]; } -message StatusRequest { - repeated string refs = 1; - repeated string prefix = 2; -} - -message StatusResponse { - google.protobuf.Timestamp started_at = 1 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; - google.protobuf.Timestamp updated_at = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; - string ref = 3; - int64 offset = 4; - int64 total = 5; +message AbortRequest { + string ref = 1; } diff --git a/api/services/execution/execution.pb.go b/api/services/execution/execution.pb.go index bbd0d3eb4..d2015dec0 100644 --- a/api/services/execution/execution.pb.go +++ b/api/services/execution/execution.pb.go @@ -3503,7 +3503,7 @@ func init() { var fileDescriptorExecution = []byte{ // 854 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x55, 0x4f, 0x8f, 0xdb, 0x44, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x4f, 0x8f, 0xdb, 0x44, 0x14, 0x5f, 0xe7, 0x8f, 0x37, 0x7d, 0xd9, 0x94, 0x32, 0x5a, 0xad, 0x8c, 0x91, 0x92, 0xc8, 0xb4, 0x25, 0x5c, 0x1c, 0x58, 0x6e, 0x08, 0x90, 0xb2, 0xd9, 0xa8, 0xaa, 0x4a, 0xe9, 0xe2, 0x20, 0x71, 0xac, 0xbc, 0xf1, 0x6c, 0x32, 0x92, 0xe3, 0x31, 0x9e, 0xf1, 0xb2, 0xb9, 0xc1, 0x9d, 0x03, 0x5f, diff --git a/api/services/images/images.pb.go b/api/services/images/images.pb.go index 40680b07d..63bfcde1d 100644 --- a/api/services/images/images.pb.go +++ b/api/services/images/images.pb.go @@ -1335,7 +1335,7 @@ func init() { var fileDescriptorImages = []byte{ // 419 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x52, 0x4d, 0x6f, 0xd3, 0x40, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x4d, 0x6f, 0xd3, 0x40, 0x10, 0xcd, 0x36, 0xa9, 0x25, 0xc6, 0xe4, 0xb2, 0xaa, 0x90, 0x71, 0x91, 0x6b, 0x99, 0x4b, 0xc5, 0x61, 0x0d, 0xe6, 0x02, 0x52, 0x29, 0x22, 0x2a, 0x54, 0x48, 0x1c, 0x2a, 0x1f, 0xb9, 0x39, 0xee, 0x60, 0x2c, 0xd5, 0x5e, 0xe3, 0x5d, 0x57, 0xca, 0x0d, 0xfe, 0x5d, 0x8e, 0x1c, 0x39, 0x21, 0xe2, diff --git a/api/services/rootfs/rootfs.pb.go b/api/services/rootfs/rootfs.pb.go index 1335eeeb0..b012d6984 100644 --- a/api/services/rootfs/rootfs.pb.go +++ b/api/services/rootfs/rootfs.pb.go @@ -1103,7 +1103,7 @@ func init() { var fileDescriptorRootfs = []byte{ // 428 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x52, 0x4d, 0xab, 0xd3, 0x40, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x52, 0x4d, 0xab, 0xd3, 0x40, 0x14, 0xed, 0xf8, 0x24, 0xad, 0x23, 0x7d, 0x8b, 0xc1, 0x45, 0x08, 0x9a, 0x94, 0xb8, 0x29, 0x82, 0x09, 0xd6, 0x85, 0x1b, 0x5d, 0xf8, 0x5e, 0x2c, 0xbe, 0x85, 0x20, 0x11, 0xd1, 0x9d, 0x4c, 0x93, 0x31, 0x1d, 0x6c, 0xe7, 0x8e, 0x33, 0xd3, 0x42, 0x77, 0xfe, 0x0e, 0x7f, 0x51, 0x97, 0x2e, 0x45, diff --git a/api/services/shim/shim.pb.go b/api/services/shim/shim.pb.go index ef4432787..b19c1cc93 100644 --- a/api/services/shim/shim.pb.go +++ b/api/services/shim/shim.pb.go @@ -3468,7 +3468,7 @@ func init() { var fileDescriptorShim = []byte{ // 913 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x55, 0x4f, 0x6f, 0xe3, 0x44, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x4f, 0x6f, 0xe3, 0x44, 0x14, 0xaf, 0x93, 0xd4, 0x4d, 0x5f, 0xd6, 0x5d, 0x18, 0x55, 0x95, 0x37, 0x45, 0x49, 0xb1, 0x84, 0xc8, 0x2e, 0x92, 0x03, 0xd9, 0x1b, 0x82, 0x43, 0xbb, 0x2d, 0x62, 0x61, 0x91, 0xa2, 0xe9, 0xde, 0x90, 0xa8, 0xdc, 0x78, 0x9a, 0x8c, 0x64, 0x7b, 0x8c, 0x67, 0x5c, 0x36, 0x37, 0xce, 0x9c, 0xb8, diff --git a/api/types/container/container.pb.go b/api/types/container/container.pb.go index e2444ac32..b1e66024b 100644 --- a/api/types/container/container.pb.go +++ b/api/types/container/container.pb.go @@ -1364,7 +1364,7 @@ func init() { var fileDescriptorContainer = []byte{ // 576 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x8c, 0x52, 0xcf, 0x6e, 0xd3, 0x4e, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcf, 0x6e, 0xd3, 0x4e, 0x18, 0xcc, 0xda, 0xce, 0xbf, 0x2f, 0x6a, 0x7e, 0xd6, 0xfe, 0x10, 0x32, 0x41, 0x4a, 0xa2, 0x08, 0x09, 0x0b, 0x09, 0x47, 0xa4, 0x17, 0xae, 0x6e, 0x6d, 0x95, 0x0a, 0xe1, 0x84, 0x8d, 0x23, 0x7a, 0x8b, 0xdc, 0x78, 0x31, 0x8b, 0x1a, 0xdb, 0xb2, 0xd7, 0x85, 0xde, 0x78, 0x04, 0x9e, 0x81, 0xa7, diff --git a/api/types/descriptor/descriptor.pb.go b/api/types/descriptor/descriptor.pb.go index 4062abcbb..e379da30d 100644 --- a/api/types/descriptor/descriptor.pb.go +++ b/api/types/descriptor/descriptor.pb.go @@ -404,7 +404,7 @@ func init() { var fileDescriptorDescriptor = []byte{ // 229 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x72, 0x4b, 0xcf, 0x2c, 0xc9, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x4b, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d, 0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0xa7, 0xa4, 0x16, 0x27, 0x17, 0x65, 0x16, 0x94, 0xe4, 0x17, 0x21, 0x31, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, diff --git a/api/types/mount/mount.pb.go b/api/types/mount/mount.pb.go index c509ea18a..1748f6eb3 100644 --- a/api/types/mount/mount.pb.go +++ b/api/types/mount/mount.pb.go @@ -473,7 +473,7 @@ func init() { var fileDescriptorMount = []byte{ // 197 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xb2, 0x49, 0xcf, 0x2c, 0xc9, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x49, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xce, 0xcf, 0x2b, 0x49, 0xcc, 0xcc, 0x4b, 0x2d, 0x4a, 0x41, 0x66, 0x26, 0x16, 0x64, 0xea, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0xe7, 0xe6, 0x97, 0xe6, 0x95, 0x40, 0x48, 0xbd, 0x82, 0xa2, 0xfc, 0x92, 0x7c, 0x21, 0x61, 0x84, 0x3a, 0xbd, 0x32, diff --git a/cmd/containerd/main.go b/cmd/containerd/main.go index c9ad9374d..e8d3c3dd8 100644 --- a/cmd/containerd/main.go +++ b/cmd/containerd/main.go @@ -242,7 +242,7 @@ func serveDebugAPI() error { return nil } -func resolveContentStore() (*content.Store, error) { +func resolveContentStore() (content.Store, error) { cp := filepath.Join(conf.Root, "content") return content.NewStore(cp) } @@ -315,7 +315,7 @@ func loadMonitor() (plugin.ContainerMonitor, error) { return plugin.NewMultiContainerMonitor(monitors...), nil } -func loadSnapshotter(store *content.Store) (snapshot.Snapshotter, error) { +func loadSnapshotter(store content.Store) (snapshot.Snapshotter, error) { for name, sr := range plugin.Registrations() { if sr.Type != plugin.SnapshotPlugin { continue @@ -356,7 +356,7 @@ func newGRPCServer() *grpc.Server { return s } -func loadServices(runtimes map[string]containerd.Runtime, store *content.Store, sn snapshot.Snapshotter, meta *bolt.DB) ([]plugin.Service, error) { +func loadServices(runtimes map[string]containerd.Runtime, store content.Store, sn snapshot.Snapshotter, meta *bolt.DB) ([]plugin.Service, error) { var o []plugin.Service for name, sr := range plugin.Registrations() { if sr.Type != plugin.GRPCPlugin { diff --git a/cmd/ctr/run.go b/cmd/ctr/run.go index 37a1d6d2a..14fcdf92b 100644 --- a/cmd/ctr/run.go +++ b/cmd/ctr/run.go @@ -78,7 +78,7 @@ var runCommand = cli.Command{ return err } - provider, err := getContentProvider(context) + content, err := getContentStore(context) if err != nil { return err } @@ -102,7 +102,7 @@ var runCommand = cli.Command{ } // let's close out our db and tx so we don't hold the lock whilst running. - diffIDs, err := image.RootFS(ctx, provider) + diffIDs, err := image.RootFS(ctx, content) if err != nil { return err } @@ -123,13 +123,13 @@ var runCommand = cli.Command{ return err } - ic, err := image.Config(ctx, provider) + ic, err := image.Config(ctx, content) if err != nil { return err } switch ic.MediaType { case ocispec.MediaTypeImageConfig, images.MediaTypeDockerSchema2Config: - r, err := provider.Reader(ctx, ic.Digest) + r, err := content.Reader(ctx, ic.Digest) if err != nil { return err } diff --git a/cmd/ctr/utils.go b/cmd/ctr/utils.go index 2254003d2..f6bb22059 100644 --- a/cmd/ctr/utils.go +++ b/cmd/ctr/utils.go @@ -35,12 +35,12 @@ func getExecutionService(context *cli.Context) (execution.ContainerServiceClient return execution.NewContainerServiceClient(conn), nil } -func getContentProvider(context *cli.Context) (content.Provider, error) { +func getContentStore(context *cli.Context) (content.Store, error) { conn, err := getGRPCConnection(context) if err != nil { return nil, err } - return contentservice.NewProviderFromClient(contentapi.NewContentClient(conn)), nil + return contentservice.NewStoreFromClient(contentapi.NewContentClient(conn)), nil } func getRootFSService(context *cli.Context) (rootfsapi.RootFSClient, error) { diff --git a/cmd/dist/active.go b/cmd/dist/active.go index 24b39a65e..d339f6e18 100644 --- a/cmd/dist/active.go +++ b/cmd/dist/active.go @@ -13,7 +13,7 @@ import ( var activeCommand = cli.Command{ Name: "active", Usage: "display active transfers.", - ArgsUsage: "[flags] [, ...]", + ArgsUsage: "[flags] []", Description: `Display the ongoing transfers.`, Flags: []cli.Flag{ cli.DurationFlag{ @@ -28,12 +28,19 @@ var activeCommand = cli.Command{ }, }, Action: func(context *cli.Context) error { + var ( + match = context.Args().First() + ) + + ctx, cancel := appContext() + defer cancel() + cs, err := resolveContentStore(context) if err != nil { return err } - active, err := cs.Active() + active, err := cs.Status(ctx, match) if err != nil { return err } diff --git a/cmd/dist/common.go b/cmd/dist/common.go index d54459239..34abc2b76 100644 --- a/cmd/dist/common.go +++ b/cmd/dist/common.go @@ -12,11 +12,13 @@ import ( "time" "github.com/containerd/console" + contentapi "github.com/containerd/containerd/api/services/content" imagesapi "github.com/containerd/containerd/api/services/images" "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" + contentservice "github.com/containerd/containerd/services/content" imagesservice "github.com/containerd/containerd/services/images" "github.com/pkg/errors" "github.com/urfave/cli" @@ -42,7 +44,7 @@ var registryFlags = []cli.Flag{ }, } -func resolveContentStore(context *cli.Context) (*content.Store, error) { +func resolveContentStore(context *cli.Context) (content.Store, error) { root := filepath.Join(context.GlobalString("root"), "content") if !filepath.IsAbs(root) { var err error @@ -51,7 +53,12 @@ func resolveContentStore(context *cli.Context) (*content.Store, error) { return nil, err } } - return content.NewStore(root) + conn, err := connectGRPC(context) + if err != nil { + return nil, err + } + + return contentservice.NewStoreFromClient(contentapi.NewContentClient(conn)), nil } func resolveImageStore(clicontext *cli.Context) (images.Store, error) { diff --git a/cmd/dist/edit.go b/cmd/dist/edit.go index 61d2496b0..0a0ad039f 100644 --- a/cmd/dist/edit.go +++ b/cmd/dist/edit.go @@ -9,7 +9,7 @@ import ( "os/exec" contentapi "github.com/containerd/containerd/api/services/content" - contentservice "github.com/containerd/containerd/services/content" + "github.com/containerd/containerd/services/content" digest "github.com/opencontainers/go-digest" "github.com/urfave/cli" ) @@ -50,10 +50,9 @@ var editCommand = cli.Command{ return err } - provider := contentservice.NewProviderFromClient(contentapi.NewContentClient(conn)) - ingester := contentservice.NewIngesterFromClient(contentapi.NewContentClient(conn)) + content := content.NewStoreFromClient(contentapi.NewContentClient(conn)) - rc, err := provider.Reader(ctx, dgst) + rc, err := content.Reader(ctx, dgst) if err != nil { return err } @@ -65,7 +64,7 @@ var editCommand = cli.Command{ } defer nrc.Close() - wr, err := ingester.Writer(ctx, "edit-"+object, 0, "") // TODO(stevvooe): Choose a better key? + wr, err := content.Writer(ctx, "edit-"+object, 0, "") // TODO(stevvooe): Choose a better key? if err != nil { return err } diff --git a/cmd/dist/fetch.go b/cmd/dist/fetch.go index 09cff8c88..a9c911c90 100644 --- a/cmd/dist/fetch.go +++ b/cmd/dist/fetch.go @@ -59,8 +59,7 @@ Most of this is experimental and there are few leaps to make this work.`, ongoing := newJobs() - ingester := contentservice.NewIngesterFromClient(contentapi.NewContentClient(conn)) - provider := contentservice.NewProviderFromClient(contentapi.NewContentClient(conn)) + content := contentservice.NewStoreFromClient(contentapi.NewContentClient(conn)) // TODO(stevvooe): Need to replace this with content store client. cs, err := resolveContentStore(clicontext) @@ -85,8 +84,8 @@ Most of this is experimental and there are few leaps to make this work.`, ongoing.add(remotes.MakeRefKey(ctx, desc)) return nil, nil }), - remotes.FetchHandler(ingester, fetcher), - images.ChildrenHandler(provider), + remotes.FetchHandler(content, fetcher), + images.ChildrenHandler(content), ), desc) }) @@ -114,7 +113,7 @@ Most of this is experimental and there are few leaps to make this work.`, activeSeen := map[string]struct{}{} if !done { - active, err := cs.Active() + active, err := cs.Status(ctx, "") if err != nil { log.G(ctx).WithError(err).Error("active check failed") continue diff --git a/cmd/dist/get.go b/cmd/dist/get.go index cee3a2536..b36b0e3cb 100644 --- a/cmd/dist/get.go +++ b/cmd/dist/get.go @@ -4,8 +4,6 @@ import ( "io" "os" - contentapi "github.com/containerd/containerd/api/services/content" - contentservice "github.com/containerd/containerd/services/content" digest "github.com/opencontainers/go-digest" "github.com/urfave/cli" ) @@ -25,13 +23,11 @@ var getCommand = cli.Command{ return err } - conn, err := connectGRPC(context) + cs, err := resolveContentStore(context) if err != nil { return err } - cs := contentservice.NewProviderFromClient(contentapi.NewContentClient(conn)) - rc, err := cs.Reader(ctx, dgst) if err != nil { return err diff --git a/cmd/dist/images.go b/cmd/dist/images.go index 78d83dc9d..b59cdd53f 100644 --- a/cmd/dist/images.go +++ b/cmd/dist/images.go @@ -5,10 +5,8 @@ import ( "os" "text/tabwriter" - contentapi "github.com/containerd/containerd/api/services/content" "github.com/containerd/containerd/log" "github.com/containerd/containerd/progress" - contentservice "github.com/containerd/containerd/services/content" "github.com/pkg/errors" "github.com/urfave/cli" ) @@ -29,13 +27,11 @@ var imagesListCommand = cli.Command{ return err } - conn, err := connectGRPC(clicontext) + cs, err := resolveContentStore(clicontext) if err != nil { return err } - provider := contentservice.NewProviderFromClient(contentapi.NewContentClient(conn)) - images, err := imageStore.List(ctx) if err != nil { return errors.Wrap(err, "failed to list images") @@ -44,7 +40,7 @@ var imagesListCommand = cli.Command{ tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, ' ', 0) fmt.Fprintln(tw, "REF\tTYPE\tDIGEST\tSIZE\t") for _, image := range images { - size, err := image.Size(ctx, provider) + size, err := image.Size(ctx, cs) if err != nil { log.G(ctx).WithError(err).Errorf("failed calculating size for image %s", image.Name) } diff --git a/cmd/dist/ingest.go b/cmd/dist/ingest.go index 2f8c77e3f..03d16e0ba 100644 --- a/cmd/dist/ingest.go +++ b/cmd/dist/ingest.go @@ -3,9 +3,7 @@ package main import ( "os" - contentapi "github.com/containerd/containerd/api/services/content" "github.com/containerd/containerd/content" - contentservice "github.com/containerd/containerd/services/content" "github.com/opencontainers/go-digest" "github.com/pkg/errors" "github.com/urfave/cli" @@ -40,20 +38,18 @@ var ingestCommand = cli.Command{ return err } - conn, err := connectGRPC(context) - if err != nil { - return err - } - if ref == "" { return errors.New("must specify a transaction reference") } - ingester := contentservice.NewIngesterFromClient(contentapi.NewContentClient(conn)) + cs, err := resolveContentStore(context) + if err != nil { + return err + } // TODO(stevvooe): Allow ingest to be reentrant. Currently, we expect // all data to be written in a single invocation. Allow multiple writes // to the same transaction key followed by a commit. - return content.WriteBlob(ctx, ingester, ref, os.Stdin, expectedSize, expectedDigest) + return content.WriteBlob(ctx, cs, ref, os.Stdin, expectedSize, expectedDigest) }, } diff --git a/cmd/dist/list.go b/cmd/dist/list.go index fb1ab8611..9a73b0123 100644 --- a/cmd/dist/list.go +++ b/cmd/dist/list.go @@ -9,7 +9,6 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/log" units "github.com/docker/go-units" - digest "github.com/opencontainers/go-digest" "github.com/urfave/cli" ) @@ -46,8 +45,8 @@ var listCommand = cli.Command{ var walkFn content.WalkFunc if quiet { - walkFn = func(path string, fi os.FileInfo, dgst digest.Digest) error { - fmt.Println(dgst) + walkFn = func(info content.Info) error { + fmt.Println(info.Digest) return nil } } else { @@ -55,16 +54,16 @@ var listCommand = cli.Command{ defer tw.Flush() fmt.Fprintln(tw, "DIGEST\tSIZE\tAGE") - walkFn = func(path string, fi os.FileInfo, dgst digest.Digest) error { + walkFn = func(info content.Info) error { fmt.Fprintf(tw, "%s\t%s\t%s\n", - dgst, - units.HumanSize(float64(fi.Size())), - units.HumanDuration(time.Since(fi.ModTime()))) + info.Digest, + units.HumanSize(float64(info.Size)), + units.HumanDuration(time.Since(info.CommittedAt))) return nil } } - return cs.Walk(walkFn) + return cs.Walk(ctx, walkFn) }, } diff --git a/cmd/dist/pull.go b/cmd/dist/pull.go index 26cb80a62..50791081d 100644 --- a/cmd/dist/pull.go +++ b/cmd/dist/pull.go @@ -7,14 +7,12 @@ import ( "text/tabwriter" "time" - contentapi "github.com/containerd/containerd/api/services/content" rootfsapi "github.com/containerd/containerd/api/services/rootfs" "github.com/containerd/containerd/content" "github.com/containerd/containerd/images" "github.com/containerd/containerd/log" "github.com/containerd/containerd/progress" "github.com/containerd/containerd/remotes" - contentservice "github.com/containerd/containerd/services/content" rootfsservice "github.com/containerd/containerd/services/rootfs" "github.com/opencontainers/image-spec/identity" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -44,7 +42,7 @@ command. As part of this process, we do the following: ctx, cancel := appContext() defer cancel() - conn, err := connectGRPC(clicontext) + cs, err := resolveContentStore(clicontext) if err != nil { return err } @@ -60,15 +58,6 @@ command. As part of this process, we do the following: } ongoing := newJobs() - // TODO(stevvooe): Must unify this type. - ingester := contentservice.NewIngesterFromClient(contentapi.NewContentClient(conn)) - provider := contentservice.NewProviderFromClient(contentapi.NewContentClient(conn)) - - cs, err := resolveContentStore(clicontext) - if err != nil { - return err - } - eg, ctx := errgroup.WithContext(ctx) var resolvedImageName string @@ -93,8 +82,8 @@ command. As part of this process, we do the following: ongoing.add(remotes.MakeRefKey(ctx, desc)) return nil, nil }), - remotes.FetchHandler(ingester, fetcher), - images.ChildrenHandler(provider)), + remotes.FetchHandler(cs, fetcher), + images.ChildrenHandler(cs)), desc) }) @@ -118,9 +107,7 @@ command. As part of this process, we do the following: log.G(ctx).Fatal(err) } - provider := contentservice.NewProviderFromClient(contentapi.NewContentClient(conn)) - - p, err := content.ReadBlob(ctx, provider, image.Target.Digest) + p, err := content.ReadBlob(ctx, cs, image.Target.Digest) if err != nil { log.G(ctx).Fatal(err) } @@ -130,6 +117,10 @@ command. As part of this process, we do the following: log.G(ctx).Fatal(err) } + conn, err := connectGRPC(clicontext) + if err != nil { + log.G(ctx).Fatal(err) + } rootfs := rootfsservice.NewUnpackerFromClient(rootfsapi.NewRootFSClient(conn)) log.G(ctx).Info("unpacking rootfs") @@ -138,7 +129,7 @@ command. As part of this process, we do the following: log.G(ctx).Fatal(err) } - diffIDs, err := image.RootFS(ctx, provider) + diffIDs, err := image.RootFS(ctx, cs) if err != nil { log.G(ctx).WithError(err).Fatal("failed resolving rootfs") } @@ -168,7 +159,7 @@ command. As part of this process, we do the following: activeSeen := map[string]struct{}{} if !done { - active, err := cs.Active() + active, err := cs.Status(ctx, "") if err != nil { log.G(ctx).WithError(err).Error("active check failed") continue diff --git a/cmd/dist/rootfs.go b/cmd/dist/rootfs.go index 8adf810e6..0e97da8ca 100644 --- a/cmd/dist/rootfs.go +++ b/cmd/dist/rootfs.go @@ -8,11 +8,9 @@ import ( "os" "strings" - contentapi "github.com/containerd/containerd/api/services/content" rootfsapi "github.com/containerd/containerd/api/services/rootfs" "github.com/containerd/containerd/content" "github.com/containerd/containerd/log" - contentservice "github.com/containerd/containerd/services/content" rootfsservice "github.com/containerd/containerd/services/rootfs" digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" @@ -49,8 +47,12 @@ var rootfsUnpackCommand = cli.Command{ return err } - provider := contentservice.NewProviderFromClient(contentapi.NewContentClient(conn)) - m, err := resolveManifest(ctx, provider, dgst) + cs, err := resolveContentStore(clicontext) + if err != nil { + return err + } + + m, err := resolveManifest(ctx, cs, dgst) if err != nil { return err } diff --git a/content/content.go b/content/content.go index 1f97ff783..7c02ded53 100644 --- a/content/content.go +++ b/content/content.go @@ -28,24 +28,62 @@ var ( } ) +type Provider interface { + Reader(ctx context.Context, dgst digest.Digest) (io.ReadCloser, error) +} + +type Ingester interface { + Writer(ctx context.Context, ref string, size int64, expected digest.Digest) (Writer, error) +} + +// TODO(stevvooe): Consider a very different name for this struct. Info is way +// to general. It also reads very weird in certain context, like pluralization. type Info struct { Digest digest.Digest Size int64 CommittedAt time.Time } -type Provider interface { - Reader(ctx context.Context, dgst digest.Digest) (io.ReadCloser, error) -} - type Status struct { Ref string Offset int64 Total int64 + Expected digest.Digest StartedAt time.Time UpdatedAt time.Time } +// WalkFunc defines the callback for a blob walk. +type WalkFunc func(Info) error + +// Manager provides methods for inspecting, listing and removing content. +type Manager interface { + // Info will return metadata about content available in the content store. + // + // If the content is not present, ErrNotFound will be returned. + Info(ctx context.Context, dgst digest.Digest) (Info, error) + + // Walk will call fn for each item in the content store. + Walk(ctx context.Context, fn WalkFunc) error + + // Delete removes the content from the store. + Delete(ctx context.Context, dgst digest.Digest) error + + // Status returns the status of any active ingestions whose ref match the + // provided regular expression. If empty, all active ingestions will be + // returned. + // + // TODO(stevvooe): Status may be slighly out of place here. If this remains + // here, we should remove Manager and just define these on store. + Status(ctx context.Context, re string) ([]Status, error) + + // Abort completely cancels the ingest operation targeted by ref. + // + // TODO(stevvooe): Same consideration as above. This should really be + // restricted to an ingest management interface. + Abort(ctx context.Context, ref string) error +} + type Writer interface { io.WriteCloser Status() (Status, error) @@ -54,8 +92,12 @@ type Writer interface { Truncate(size int64) error } -type Ingester interface { - Writer(ctx context.Context, ref string, size int64, expected digest.Digest) (Writer, error) +// Store combines the methods of content-oriented interfaces into a set that +// are commonly provided by complete implementations. +type Store interface { + Manager + Ingester + Provider } func IsNotFound(err error) bool { diff --git a/content/content_test.go b/content/content_test.go index 35f7256a0..8942cbf03 100644 --- a/content/content_test.go +++ b/content/content_test.go @@ -52,7 +52,7 @@ func TestContentWriter(t *testing.T) { } // we should also see this as an active ingestion - ingestions, err := cs.Active() + ingestions, err := cs.Status(ctx, "") if err != nil { t.Fatal(err) } @@ -132,11 +132,9 @@ func TestWalkBlobs(t *testing.T) { expected[dgst] = struct{}{} } - if err := cs.Walk(func(path string, fi os.FileInfo, dgst digest.Digest) error { - found[dgst] = struct{}{} - if checked := checkBlobPath(t, cs, dgst); checked != path { - t.Fatalf("blob path did not match: %v != %v", path, checked) - } + if err := cs.Walk(ctx, func(bi Info) error { + found[bi.Digest] = struct{}{} + checkBlobPath(t, cs, bi.Digest) return nil }); err != nil { t.Fatal(err) @@ -203,7 +201,7 @@ func generateBlobs(t checker, nblobs, maxsize int64) map[digest.Digest][]byte { return blobs } -func populateBlobStore(t checker, ctx context.Context, cs *Store, nblobs, maxsize int64) map[digest.Digest][]byte { +func populateBlobStore(t checker, ctx context.Context, cs Store, nblobs, maxsize int64) map[digest.Digest][]byte { blobs := generateBlobs(t, nblobs, maxsize) for dgst, p := range blobs { @@ -213,7 +211,7 @@ func populateBlobStore(t checker, ctx context.Context, cs *Store, nblobs, maxsiz return blobs } -func contentStoreEnv(t checker) (context.Context, string, *Store, func()) { +func contentStoreEnv(t checker) (context.Context, string, Store, func()) { pc, _, _, ok := runtime.Caller(1) if !ok { t.Fatal("failed to resolve caller") @@ -249,10 +247,10 @@ func checkCopy(t checker, size int64, dst io.Writer, src io.Reader) { } } -func checkBlobPath(t *testing.T, cs *Store, dgst digest.Digest) string { - path := cs.blobPath(dgst) +func checkBlobPath(t *testing.T, cs Store, dgst digest.Digest) string { + path := cs.(*store).blobPath(dgst) - if path != filepath.Join(cs.root, "blobs", dgst.Algorithm().String(), dgst.Hex()) { + if path != filepath.Join(cs.(*store).root, "blobs", dgst.Algorithm().String(), dgst.Hex()) { t.Fatalf("unexpected path: %q", path) } fi, err := os.Stat(path) @@ -268,7 +266,7 @@ func checkBlobPath(t *testing.T, cs *Store, dgst digest.Digest) string { return path } -func checkWrite(t checker, ctx context.Context, cs *Store, dgst digest.Digest, p []byte) digest.Digest { +func checkWrite(t checker, ctx context.Context, cs Store, dgst digest.Digest, p []byte) digest.Digest { if err := WriteBlob(ctx, cs, dgst.String(), bytes.NewReader(p), int64(len(p)), dgst); err != nil { t.Fatal(err) } diff --git a/content/store.go b/content/store.go index 2bf3c540a..f1d59caf3 100644 --- a/content/store.go +++ b/content/store.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "os" "path/filepath" + "regexp" "strconv" "time" @@ -21,21 +22,21 @@ import ( // // Store can generally support multi-reader, single-writer ingest of data, // including resumable ingest. -type Store struct { +type store struct { root string } -func NewStore(root string) (*Store, error) { +func NewStore(root string) (Store, error) { if err := os.MkdirAll(filepath.Join(root, "ingest"), 0777); err != nil && !os.IsExist(err) { return nil, err } - return &Store{ + return &store{ root: root, }, nil } -func (s *Store) Info(dgst digest.Digest) (Info, error) { +func (s *store) Info(ctx context.Context, dgst digest.Digest) (Info, error) { p := s.blobPath(dgst) fi, err := os.Stat(p) if err != nil { @@ -46,11 +47,15 @@ func (s *Store) Info(dgst digest.Digest) (Info, error) { return Info{}, err } + return s.info(dgst, fi), nil +} + +func (s *store) info(dgst digest.Digest, fi os.FileInfo) Info { return Info{ Digest: dgst, Size: fi.Size(), CommittedAt: fi.ModTime(), - }, nil + } } // Open returns an io.ReadCloser for the blob. @@ -58,7 +63,7 @@ func (s *Store) Info(dgst digest.Digest) (Info, error) { // TODO(stevvooe): This would work much better as an io.ReaderAt in practice. // Right now, we are doing type assertion to tease that out, but it won't scale // well. -func (s *Store) Reader(ctx context.Context, dgst digest.Digest) (io.ReadCloser, error) { +func (s *store) Reader(ctx context.Context, dgst digest.Digest) (io.ReadCloser, error) { fp, err := os.Open(s.blobPath(dgst)) if err != nil { if os.IsNotExist(err) { @@ -74,7 +79,7 @@ func (s *Store) Reader(ctx context.Context, dgst digest.Digest) (io.ReadCloser, // // While this is safe to do concurrently, safe exist-removal logic must hold // some global lock on the store. -func (cs *Store) Delete(dgst digest.Digest) error { +func (cs *store) Delete(ctx context.Context, dgst digest.Digest) error { if err := os.RemoveAll(cs.blobPath(dgst)); err != nil { if !os.IsNotExist(err) { return err @@ -88,14 +93,7 @@ func (cs *Store) Delete(dgst digest.Digest) error { // TODO(stevvooe): Allow querying the set of blobs in the blob store. -// WalkFunc defines the callback for a blob walk. -// -// TODO(stevvooe): Remove the file info. Just need size and modtime. Perhaps, -// not a huge deal, considering we have a path, but let's not just let this one -// go without scrutiny. -type WalkFunc func(path string, fi os.FileInfo, dgst digest.Digest) error - -func (cs *Store) Walk(fn WalkFunc) error { +func (cs *store) Walk(ctx context.Context, fn WalkFunc) error { root := filepath.Join(cs.root, "blobs") var alg digest.Algorithm return filepath.Walk(root, func(path string, fi os.FileInfo, err error) error { @@ -133,17 +131,60 @@ func (cs *Store) Walk(fn WalkFunc) error { // store or extra paths not expected previously. } - return fn(path, fi, dgst) + return fn(cs.info(dgst, fi)) }) } -// Status returns the current status of a blob by the ingest ref. -func (s *Store) Status(ref string) (Status, error) { - return s.status(s.ingestRoot(ref)) +func (s *store) Status(ctx context.Context, re string) ([]Status, error) { + fp, err := os.Open(filepath.Join(s.root, "ingest")) + if err != nil { + return nil, err + } + + defer fp.Close() + + fis, err := fp.Readdir(-1) + if err != nil { + return nil, err + } + + rec, err := regexp.Compile(re) + if err != nil { + return nil, err + } + + var active []Status + for _, fi := range fis { + p := filepath.Join(s.root, "ingest", fi.Name()) + stat, err := s.status(p) + if err != nil { + if !os.IsNotExist(err) { + return nil, err + } + + // TODO(stevvooe): This is a common error if uploads are being + // completed while making this listing. Need to consider taking a + // lock on the whole store to coordinate this aspect. + // + // Another option is to cleanup downloads asynchronously and + // coordinate this method with the cleanup process. + // + // For now, we just skip them, as they really don't exist. + continue + } + + if !rec.MatchString(stat.Ref) { + continue + } + + active = append(active, stat) + } + + return active, nil } // status works like stat above except uses the path to the ingest. -func (s *Store) status(ingestPath string) (Status, error) { +func (s *store) status(ingestPath string) (Status, error) { dp := filepath.Join(ingestPath, "data") fi, err := os.Stat(dp) if err != nil { @@ -165,7 +206,7 @@ func (s *Store) status(ingestPath string) (Status, error) { } // total attempts to resolve the total expected size for the write. -func (s *Store) total(ingestPath string) int64 { +func (s *store) total(ingestPath string) int64 { totalS, err := readFileString(filepath.Join(ingestPath, "total")) if err != nil { return 0 @@ -185,7 +226,10 @@ func (s *Store) total(ingestPath string) int64 { // ref at a time. // // The argument `ref` is used to uniquely identify a long-lived writer transaction. -func (s *Store) Writer(ctx context.Context, ref string, total int64, expected digest.Digest) (Writer, error) { +func (s *store) Writer(ctx context.Context, ref string, total int64, expected digest.Digest) (Writer, error) { + // TODO(stevvooe): Need to actually store and handle expected here. We have + // code in the service that shouldn't be dealing with this. + path, refp, data, lock, err := s.ingestPaths(ref) if err != nil { return nil, err @@ -283,11 +327,11 @@ func (s *Store) Writer(ctx context.Context, ref string, total int64, expected di // Abort an active transaction keyed by ref. If the ingest is active, it will // be cancelled. Any resources associated with the ingest will be cleaned. -func (s *Store) Abort(ref string) error { +func (s *store) Abort(ctx context.Context, ref string) error { root := s.ingestRoot(ref) if err := os.RemoveAll(root); err != nil { if os.IsNotExist(err) { - return nil + return ErrNotFound } return err @@ -296,50 +340,11 @@ func (s *Store) Abort(ref string) error { return nil } -func (s *Store) Active() ([]Status, error) { - fp, err := os.Open(filepath.Join(s.root, "ingest")) - if err != nil { - return nil, err - } - - defer fp.Close() - - fis, err := fp.Readdir(-1) - if err != nil { - return nil, err - } - - var active []Status - for _, fi := range fis { - p := filepath.Join(s.root, "ingest", fi.Name()) - stat, err := s.status(p) - if err != nil { - if !os.IsNotExist(err) { - return nil, err - } - - // TODO(stevvooe): This is a common error if uploads are being - // completed while making this listing. Need to consider taking a - // lock on the whole store to coordinate this aspect. - // - // Another option is to cleanup downloads asynchronously and - // coordinate this method with the cleanup process. - // - // For now, we just skip them, as they really don't exist. - continue - } - - active = append(active, stat) - } - - return active, nil -} - -func (cs *Store) blobPath(dgst digest.Digest) string { +func (cs *store) blobPath(dgst digest.Digest) string { return filepath.Join(cs.root, "blobs", dgst.Algorithm().String(), dgst.Hex()) } -func (s *Store) ingestRoot(ref string) string { +func (s *store) ingestRoot(ref string) string { dgst := digest.FromString(ref) return filepath.Join(s.root, "ingest", dgst.Hex()) } @@ -351,7 +356,7 @@ func (s *Store) ingestRoot(ref string) string { // - data: file where data is written // - lock: lock file location // -func (s *Store) ingestPaths(ref string) (string, string, string, lockfile.Lockfile, error) { +func (s *store) ingestPaths(ref string) (string, string, string, lockfile.Lockfile, error) { var ( fp = s.ingestRoot(ref) rp = filepath.Join(fp, "ref") diff --git a/content/writer.go b/content/writer.go index e27bd0999..2a6f506a7 100644 --- a/content/writer.go +++ b/content/writer.go @@ -13,7 +13,7 @@ import ( // writer represents a write transaction against the blob store. type writer struct { - s *Store + s *store fp *os.File // opened data file lock lockfile.Lockfile path string // path to writer dir diff --git a/plugin/plugin.go b/plugin/plugin.go index 095b9e8f6..fd77bec4e 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -33,7 +33,7 @@ type InitContext struct { Root string State string Runtimes map[string]containerd.Runtime - Content *content.Store + Content content.Store Meta *bolt.DB Snapshotter snapshot.Snapshotter Config interface{} diff --git a/services/content/helpers.go b/services/content/helpers.go index 70659813c..a107bcb98 100644 --- a/services/content/helpers.go +++ b/services/content/helpers.go @@ -17,3 +17,14 @@ func rewriteGRPCError(err error) error { return err } + +func serverErrorToGRPC(err error, id string) error { + switch { + case content.IsNotFound(err): + return grpc.Errorf(codes.NotFound, "%v: not found", id) + case content.IsExists(err): + return grpc.Errorf(codes.AlreadyExists, "%v: exists", id) + } + + return err +} diff --git a/services/content/provider.go b/services/content/reader.go similarity index 60% rename from services/content/provider.go rename to services/content/reader.go index af7995abb..2abedd9c4 100644 --- a/services/content/provider.go +++ b/services/content/reader.go @@ -1,35 +1,9 @@ package content import ( - "context" - "io" - contentapi "github.com/containerd/containerd/api/services/content" - "github.com/containerd/containerd/content" - digest "github.com/opencontainers/go-digest" ) -func NewProviderFromClient(client contentapi.ContentClient) content.Provider { - return &remoteProvider{ - client: client, - } -} - -type remoteProvider struct { - client contentapi.ContentClient -} - -func (rp *remoteProvider) Reader(ctx context.Context, dgst digest.Digest) (io.ReadCloser, error) { - client, err := rp.client.Read(ctx, &contentapi.ReadRequest{Digest: dgst}) - if err != nil { - return nil, err - } - - return &remoteReader{ - client: client, - }, nil -} - type remoteReader struct { client contentapi.Content_ReadClient extra []byte diff --git a/services/content/service.go b/services/content/service.go index d02288688..662d41d65 100644 --- a/services/content/service.go +++ b/services/content/service.go @@ -18,7 +18,7 @@ import ( ) type Service struct { - store *content.Store + store content.Store } var bufPool = sync.Pool{ @@ -52,25 +52,68 @@ func (s *Service) Info(ctx context.Context, req *api.InfoRequest) (*api.InfoResp return nil, grpc.Errorf(codes.InvalidArgument, "%q failed validation", req.Digest) } - bi, err := s.store.Info(req.Digest) + bi, err := s.store.Info(ctx, req.Digest) if err != nil { - return nil, maybeNotFoundGRPC(err, req.Digest.String()) + return nil, serverErrorToGRPC(err, req.Digest.String()) } return &api.InfoResponse{ - Digest: req.Digest, - Size_: bi.Size, - CommittedAt: bi.CommittedAt, + Info: api.Info{ + Digest: bi.Digest, + Size_: bi.Size, + CommittedAt: bi.CommittedAt, + }, }, nil } +func (s *Service) List(req *api.ListContentRequest, session api.Content_ListServer) error { + var ( + buffer []api.Info + sendBlock = func(block []api.Info) error { + // send last block + return session.Send(&api.ListContentResponse{ + Info: block, + }) + } + ) + + if err := s.store.Walk(session.Context(), func(info content.Info) error { + buffer = append(buffer, api.Info{ + Digest: info.Digest, + Size_: info.Size, + CommittedAt: info.CommittedAt, + }) + + if len(buffer) >= 100 { + if err := sendBlock(buffer); err != nil { + return err + } + + buffer = buffer[:0] + } + + return nil + }); err != nil { + return err + } + + if len(buffer) > 0 { + // send last block + if err := sendBlock(buffer); err != nil { + return err + } + } + + return nil +} + func (s *Service) Delete(ctx context.Context, req *api.DeleteContentRequest) (*empty.Empty, error) { if err := req.Digest.Validate(); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, err.Error()) } - if err := s.store.Delete(req.Digest); err != nil { - return nil, maybeNotFoundGRPC(err, req.Digest.String()) + if err := s.store.Delete(ctx, req.Digest); err != nil { + return nil, serverErrorToGRPC(err, req.Digest.String()) } return &empty.Empty{}, nil @@ -81,14 +124,14 @@ func (s *Service) Read(req *api.ReadRequest, session api.Content_ReadServer) err return grpc.Errorf(codes.InvalidArgument, "%v: %v", req.Digest, err) } - oi, err := s.store.Info(req.Digest) + oi, err := s.store.Info(session.Context(), req.Digest) if err != nil { - return maybeNotFoundGRPC(err, req.Digest.String()) + return serverErrorToGRPC(err, req.Digest.String()) } rc, err := s.store.Reader(session.Context(), req.Digest) if err != nil { - return maybeNotFoundGRPC(err, req.Digest.String()) + return serverErrorToGRPC(err, req.Digest.String()) } defer rc.Close() // TODO(stevvooe): Cache these file descriptors for performance. @@ -132,6 +175,10 @@ func (s *Service) Read(req *api.ReadRequest, session api.Content_ReadServer) err return nil } +// readResponseWriter is a writer that places the output into ReadResponse messages. +// +// This allows io.CopyBuffer to do the heavy lifting of chunking the responses +// into the buffer size. type readResponseWriter struct { offset int64 session api.Content_ReadServer @@ -149,6 +196,27 @@ func (rw *readResponseWriter) Write(p []byte) (n int, err error) { return len(p), nil } +func (s *Service) Status(ctx context.Context, req *api.StatusRequest) (*api.StatusResponse, error) { + statuses, err := s.store.Status(ctx, req.Regexp) + if err != nil { + return nil, serverErrorToGRPC(err, req.Regexp) + } + + var resp api.StatusResponse + for _, status := range statuses { + resp.Statuses = append(resp.Statuses, api.Status{ + StartedAt: status.StartedAt, + UpdatedAt: status.UpdatedAt, + Ref: status.Ref, + Offset: status.Offset, + Total: status.Total, + Expected: status.Expected, + }) + } + + return &resp, nil +} + func (s *Service) Write(session api.Content_WriteServer) (err error) { var ( ctx = session.Context() @@ -243,8 +311,8 @@ func (s *Service) Write(session api.Content_WriteServer) (err error) { } expected = req.Expected - if _, err := s.store.Info(req.Expected); err == nil { - if err := s.store.Abort(ref); err != nil { + if _, err := s.store.Info(session.Context(), req.Expected); err == nil { + if err := s.store.Abort(session.Context(), ref); err != nil { log.G(ctx).WithError(err).Error("failed to abort write") } @@ -307,8 +375,6 @@ func (s *Service) Write(session api.Content_WriteServer) (err error) { } msg.Digest = wr.Digest() - case api.WriteActionAbort: - return s.store.Abort(ref) } if err := session.Send(&msg); err != nil { @@ -326,14 +392,10 @@ func (s *Service) Write(session api.Content_WriteServer) (err error) { } } -func (s *Service) Status(*api.StatusRequest, api.Content_StatusServer) error { - return grpc.Errorf(codes.Unimplemented, "not implemented") -} - -func maybeNotFoundGRPC(err error, id string) error { - if content.IsNotFound(err) { - return grpc.Errorf(codes.NotFound, "%v: not found", id) +func (s *Service) Abort(ctx context.Context, req *api.AbortRequest) (*empty.Empty, error) { + if err := s.store.Abort(ctx, req.Ref); err != nil { + return nil, serverErrorToGRPC(err, req.Ref) } - return err + return &empty.Empty{}, nil } diff --git a/services/content/store.go b/services/content/store.go new file mode 100644 index 000000000..e5c19e458 --- /dev/null +++ b/services/content/store.go @@ -0,0 +1,155 @@ +package content + +import ( + "context" + "io" + + contentapi "github.com/containerd/containerd/api/services/content" + "github.com/containerd/containerd/content" + digest "github.com/opencontainers/go-digest" +) + +type remoteStore struct { + client contentapi.ContentClient +} + +func NewStoreFromClient(client contentapi.ContentClient) content.Store { + return &remoteStore{ + client: client, + } +} + +func (rs *remoteStore) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) { + resp, err := rs.client.Info(ctx, &contentapi.InfoRequest{ + Digest: dgst, + }) + if err != nil { + return content.Info{}, rewriteGRPCError(err) + } + + return content.Info{ + Digest: resp.Info.Digest, + Size: resp.Info.Size_, + CommittedAt: resp.Info.CommittedAt, + }, nil +} + +func (rs *remoteStore) Walk(ctx context.Context, fn content.WalkFunc) error { + session, err := rs.client.List(ctx, &contentapi.ListContentRequest{}) + if err != nil { + return rewriteGRPCError(err) + } + + for { + msg, err := session.Recv() + if err != nil { + if err != io.EOF { + return rewriteGRPCError(err) + } + + break + } + + for _, info := range msg.Info { + if err := fn(content.Info{ + Digest: info.Digest, + Size: info.Size_, + CommittedAt: info.CommittedAt, + }); err != nil { + return err + } + } + } + + return nil +} + +func (rs *remoteStore) Delete(ctx context.Context, dgst digest.Digest) error { + if _, err := rs.client.Delete(ctx, &contentapi.DeleteContentRequest{ + Digest: dgst, + }); err != nil { + return rewriteGRPCError(err) + } + + return nil +} + +func (rs *remoteStore) Reader(ctx context.Context, dgst digest.Digest) (io.ReadCloser, error) { + client, err := rs.client.Read(ctx, &contentapi.ReadRequest{Digest: dgst}) + if err != nil { + return nil, err + } + + return &remoteReader{ + client: client, + }, nil +} + +func (rs *remoteStore) Status(ctx context.Context, re string) ([]content.Status, error) { + resp, err := rs.client.Status(ctx, &contentapi.StatusRequest{ + Regexp: re, + }) + if err != nil { + return nil, rewriteGRPCError(err) + } + + var statuses []content.Status + for _, status := range resp.Statuses { + statuses = append(statuses, content.Status{ + Ref: status.Ref, + StartedAt: status.StartedAt, + UpdatedAt: status.UpdatedAt, + Offset: status.Offset, + Total: status.Total, + Expected: status.Expected, + }) + } + + return statuses, nil +} + +func (rs *remoteStore) Writer(ctx context.Context, ref string, size int64, expected digest.Digest) (content.Writer, error) { + wrclient, offset, err := rs.negotiate(ctx, ref, size, expected) + if err != nil { + return nil, rewriteGRPCError(err) + } + + return &remoteWriter{ + client: wrclient, + offset: offset, + }, nil +} + +// Abort implements asynchronous abort. It starts a new write session on the ref l +func (rs *remoteStore) Abort(ctx context.Context, ref string) error { + if _, err := rs.client.Abort(ctx, &contentapi.AbortRequest{ + Ref: ref, + }); err != nil { + return rewriteGRPCError(err) + } + + return nil +} + +func (rs *remoteStore) negotiate(ctx context.Context, ref string, size int64, expected digest.Digest) (contentapi.Content_WriteClient, int64, error) { + wrclient, err := rs.client.Write(ctx) + if err != nil { + return nil, 0, err + } + + if err := wrclient.Send(&contentapi.WriteRequest{ + Action: contentapi.WriteActionStat, + Ref: ref, + Total: size, + Expected: expected, + }); err != nil { + return nil, 0, err + } + + resp, err := wrclient.Recv() + if err != nil { + return nil, 0, err + } + + return wrclient, resp.Offset, nil +} diff --git a/services/content/ingester.go b/services/content/writer.go similarity index 70% rename from services/content/ingester.go rename to services/content/writer.go index a4182cc4f..be601448a 100644 --- a/services/content/ingester.go +++ b/services/content/writer.go @@ -1,61 +1,14 @@ package content import ( - "context" "io" contentapi "github.com/containerd/containerd/api/services/content" "github.com/containerd/containerd/content" - digest "github.com/opencontainers/go-digest" "github.com/pkg/errors" ) -func NewIngesterFromClient(client contentapi.ContentClient) content.Ingester { - return &remoteIngester{ - client: client, - } -} - -type remoteIngester struct { - client contentapi.ContentClient -} - -func (ri *remoteIngester) Writer(ctx context.Context, ref string, size int64, expected digest.Digest) (content.Writer, error) { - wrclient, offset, err := ri.negotiate(ctx, ref, size, expected) - if err != nil { - return nil, rewriteGRPCError(err) - } - - return &remoteWriter{ - client: wrclient, - offset: offset, - }, nil -} - -func (ri *remoteIngester) negotiate(ctx context.Context, ref string, size int64, expected digest.Digest) (contentapi.Content_WriteClient, int64, error) { - wrclient, err := ri.client.Write(ctx) - if err != nil { - return nil, 0, err - } - - if err := wrclient.Send(&contentapi.WriteRequest{ - Action: contentapi.WriteActionStat, - Ref: ref, - Total: size, - Expected: expected, - }); err != nil { - return nil, 0, err - } - - resp, err := wrclient.Recv() - if err != nil { - return nil, 0, err - } - - return wrclient, resp.Offset, nil -} - type remoteWriter struct { ref string client contentapi.Content_WriteClient diff --git a/services/rootfs/service.go b/services/rootfs/service.go index 2ed937e06..685de5b4a 100644 --- a/services/rootfs/service.go +++ b/services/rootfs/service.go @@ -26,11 +26,11 @@ func init() { } type Service struct { - store *content.Store + store content.Store snapshotter snapshot.Snapshotter } -func NewService(store *content.Store, snapshotter snapshot.Snapshotter) (*Service, error) { +func NewService(store content.Store, snapshotter snapshot.Snapshotter) (*Service, error) { return &Service{ store: store, snapshotter: snapshotter, diff --git a/snapshot/storage/proto/record.pb.go b/snapshot/storage/proto/record.pb.go index 7eb8d67c6..e8081c686 100644 --- a/snapshot/storage/proto/record.pb.go +++ b/snapshot/storage/proto/record.pb.go @@ -512,7 +512,7 @@ func init() { var fileDescriptorRecord = []byte{ // 330 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x54, 0x90, 0xbd, 0x4e, 0xf3, 0x30, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xbd, 0x4e, 0xf3, 0x30, 0x18, 0x85, 0xe3, 0x7c, 0xf9, 0x42, 0x6b, 0xd1, 0xaa, 0x18, 0x54, 0x59, 0x19, 0x8c, 0xc5, 0x42, 0xc4, 0x90, 0x08, 0xb8, 0x82, 0xfe, 0x0d, 0x55, 0x55, 0x21, 0x85, 0x8a, 0x3d, 0x8d, 0xad, 0xd4, 0x82, 0xda, 0x95, 0x63, 0x2a, 0xc1, 0xc4, 0x88, 0x7a, 0x0f, 0x9d, 0x60, 0xe3, 0x0e, 0xb8, 0x82,