Merge pull request #577 from stevvooe/content-service-delete

api/services/content: define delete method
This commit is contained in:
Stephen Day 2017-02-28 10:25:37 -08:00 committed by GitHub
commit 06701b23cb
5 changed files with 269 additions and 62 deletions

View file

@ -11,6 +11,7 @@
It has these top-level messages:
InfoRequest
InfoResponse
DeleteContentRequest
ReadRequest
ReadResponse
WriteRequest
@ -25,6 +26,7 @@ import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import _ "github.com/gogo/protobuf/types"
import google_protobuf2 "github.com/golang/protobuf/ptypes/empty"
import github_com_opencontainers_go_digest "github.com/opencontainers/go-digest"
import time "time"
@ -121,6 +123,15 @@ func (m *InfoResponse) Reset() { *m = InfoResponse{} }
func (*InfoResponse) ProtoMessage() {}
func (*InfoResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{1} }
type DeleteContentRequest struct {
// Digest specifies which content to delete.
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 *DeleteContentRequest) Reset() { *m = DeleteContentRequest{} }
func (*DeleteContentRequest) ProtoMessage() {}
func (*DeleteContentRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{2} }
// ReadRequest defines the fields that make up a request to read a portion of
// data from a stored object.
type ReadRequest struct {
@ -137,7 +148,7 @@ type ReadRequest struct {
func (m *ReadRequest) Reset() { *m = ReadRequest{} }
func (*ReadRequest) ProtoMessage() {}
func (*ReadRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{2} }
func (*ReadRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{3} }
// ReadResponse carries byte data for a read request.
type ReadResponse struct {
@ -147,7 +158,7 @@ type ReadResponse struct {
func (m *ReadResponse) Reset() { *m = ReadResponse{} }
func (*ReadResponse) ProtoMessage() {}
func (*ReadResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{3} }
func (*ReadResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{4} }
// WriteRequest writes data to the request ref at offset.
type WriteRequest struct {
@ -198,7 +209,7 @@ type WriteRequest struct {
func (m *WriteRequest) Reset() { *m = WriteRequest{} }
func (*WriteRequest) ProtoMessage() {}
func (*WriteRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{4} }
func (*WriteRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{5} }
// WriteResponse is returned on the culmination of a write call.
type WriteResponse struct {
@ -233,7 +244,7 @@ type WriteResponse struct {
func (m *WriteResponse) Reset() { *m = WriteResponse{} }
func (*WriteResponse) ProtoMessage() {}
func (*WriteResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{5} }
func (*WriteResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{6} }
type StatusRequest struct {
Refs []string `protobuf:"bytes,1,rep,name=refs" json:"refs,omitempty"`
@ -242,7 +253,7 @@ type StatusRequest struct {
func (m *StatusRequest) Reset() { *m = StatusRequest{} }
func (*StatusRequest) ProtoMessage() {}
func (*StatusRequest) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{6} }
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"`
@ -254,11 +265,12 @@ type StatusResponse struct {
func (m *StatusResponse) Reset() { *m = StatusResponse{} }
func (*StatusResponse) ProtoMessage() {}
func (*StatusResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{7} }
func (*StatusResponse) Descriptor() ([]byte, []int) { return fileDescriptorContent, []int{8} }
func init() {
proto.RegisterType((*InfoRequest)(nil), "containerd.v1.InfoRequest")
proto.RegisterType((*InfoResponse)(nil), "containerd.v1.InfoResponse")
proto.RegisterType((*DeleteContentRequest)(nil), "containerd.v1.DeleteContentRequest")
proto.RegisterType((*ReadRequest)(nil), "containerd.v1.ReadRequest")
proto.RegisterType((*ReadResponse)(nil), "containerd.v1.ReadResponse")
proto.RegisterType((*WriteRequest)(nil), "containerd.v1.WriteRequest")
@ -284,6 +296,8 @@ 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)
// 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.
//
// The requested data may be returned in one or more messages.
@ -330,6 +344,15 @@ func (c *contentClient) Info(ctx context.Context, in *InfoRequest, opts ...grpc.
return out, 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...)
if err != nil {
return nil, err
}
return out, nil
}
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...)
if err != nil {
@ -433,6 +456,8 @@ type ContentServer interface {
// This call can be used for getting the size of content and checking for
// existence.
Info(context.Context, *InfoRequest) (*InfoResponse, 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.
//
// The requested data may be returned in one or more messages.
@ -484,6 +509,24 @@ func _Content_Info_Handler(srv interface{}, ctx context.Context, dec func(interf
return interceptor(ctx, in, info, handler)
}
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 {
return nil, err
}
if interceptor == nil {
return srv.(ContentServer).Delete(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/containerd.v1.Content/Delete",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ContentServer).Delete(ctx, req.(*DeleteContentRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Content_Read_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(ReadRequest)
if err := stream.RecvMsg(m); err != nil {
@ -560,6 +603,10 @@ var _Content_serviceDesc = grpc.ServiceDesc{
MethodName: "Info",
Handler: _Content_Info_Handler,
},
{
MethodName: "Delete",
Handler: _Content_Delete_Handler,
},
},
Streams: []grpc.StreamDesc{
{
@ -643,6 +690,30 @@ func (m *InfoResponse) MarshalTo(dAtA []byte) (int, error) {
return i, nil
}
func (m *DeleteContentRequest) 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 *DeleteContentRequest) 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)
}
return i, nil
}
func (m *ReadRequest) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@ -962,6 +1033,16 @@ func (m *InfoResponse) Size() (n int) {
return n
}
func (m *DeleteContentRequest) Size() (n int) {
var l int
_ = l
l = len(m.Digest)
if l > 0 {
n += 1 + l + sovContent(uint64(l))
}
return n
}
func (m *ReadRequest) Size() (n int) {
var l int
_ = l
@ -1114,6 +1195,16 @@ func (this *InfoResponse) String() string {
}, "")
return s
}
func (this *DeleteContentRequest) String() string {
if this == nil {
return "nil"
}
s := strings.Join([]string{`&DeleteContentRequest{`,
`Digest:` + fmt.Sprintf("%v", this.Digest) + `,`,
`}`,
}, "")
return s
}
func (this *ReadRequest) String() string {
if this == nil {
return "nil"
@ -1407,6 +1498,85 @@ func (m *InfoResponse) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *DeleteContentRequest) 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: DeleteContentRequest: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: DeleteContentRequest: 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
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 *ReadRequest) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
@ -2411,51 +2581,54 @@ func init() {
}
var fileDescriptorContent = []byte{
// 734 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4d, 0x6f,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0x7f, 0x90, 0x5a, 0x3b, 0xdb, 0xdb, 0x5b,
0xed, 0x52, 0x5a, 0xfe, 0xf7, 0xe8, 0xb8, 0xfa, 0x4f, 0xa2, 0xa2, 0xc5, 0x17, 0x11, 0xae, 0x43,
0x4e, 0x6f, 0xee, 0x18, 0xed, 0xd2, 0x8f, 0xf8, 0xef, 0x32, 0x98, 0xde, 0xa1, 0x3e, 0x93, 0x17,
0x5f, 0xbd, 0x55, 0x52, 0x1f, 0xdf, 0x29, 0xc9, 0x09, 0x1b, 0x6f, 0xd2, 0xf0, 0x57, 0x2b, 0xfa,
0xbd, 0xc0, 0x1b, 0x90, 0x0d, 0xf7, 0x30, 0xbe, 0x78, 0x0f, 0x12, 0x8b, 0x5f, 0x5e, 0x9e, 0x9a,
0x13, 0x1f, 0x52, 0x87, 0x6c, 0xb8, 0x87, 0x2e, 0x01, 0x24, 0x76, 0xe4, 0x25, 0x80, 0xe4, 0xe2,
0x5a, 0x47, 0x78, 0x13, 0xa4, 0xc8, 0x1d, 0x78, 0xe5, 0x42, 0xe1, 0x84, 0xe5, 0xe4, 0xd5, 0x5f,
0x64, 0x47, 0x40, 0xf7, 0x21, 0x17, 0x69, 0xb8, 0x3c, 0xed, 0x56, 0xc7, 0x30, 0x2b, 0xd3, 0x93,
0x11, 0x4a, 0x1d, 0xad, 0xa3, 0x66, 0xf9, 0xe4, 0x5c, 0x49, 0x7d, 0x39, 0x57, 0x52, 0x2f, 0x86,
0x0a, 0x3a, 0x19, 0x2a, 0xe8, 0xf3, 0x50, 0x41, 0xdf, 0x86, 0x0a, 0xea, 0x48, 0xdc, 0x55, 0xb7,
0x7e, 0x06, 0x00, 0x00, 0xff, 0xff, 0x8d, 0x7a, 0xfb, 0xa8, 0xa2, 0x07, 0x00, 0x00,
// 777 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcf, 0x4f, 0xdb, 0x48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a, 0x12, 0x67, 0xff, 0xd7, 0xb7, 0x00, 0x00, 0x00, 0xff,
0xff, 0xbb, 0x95, 0xf8, 0xe3, 0x6a, 0x08, 0x00, 0x00,
}

View file

@ -4,6 +4,7 @@ package containerd.v1;
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
// Content provides access to a content addressable storage system.
service Content {
@ -13,6 +14,9 @@ service Content {
// existence.
rpc Info(InfoRequest) returns (InfoResponse);
// Delete will delete the referenced object.
rpc Delete(DeleteContentRequest) returns (google.protobuf.Empty);
// Read allows one to read an object based on the offset into the content.
//
// The requested data may be returned in one or more messages.
@ -59,6 +63,11 @@ message InfoResponse {
google.protobuf.Timestamp committed_at = 3 [(gogoproto.stdtime) = true, (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];
}
// ReadRequest defines the fields that make up a request to read a portion of
// data from a stored object.
message ReadRequest {

28
cmd/dist/delete.go vendored
View file

@ -1,9 +1,12 @@
package main
import (
contextpkg "context"
"fmt"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
contentapi "github.com/docker/containerd/api/services/content"
"github.com/docker/containerd/log"
digest "github.com/opencontainers/go-digest"
"github.com/urfave/cli"
@ -11,7 +14,7 @@ import (
var deleteCommand = cli.Command{
Name: "delete",
Aliases: []string{"del"},
Aliases: []string{"delete", "del", "remove", "rm"},
Usage: "permanently delete one or more blobs.",
ArgsUsage: "[flags] [<digest>, ...]",
Description: `Delete one or more blobs permanently. Successfully deleted
@ -19,16 +22,18 @@ var deleteCommand = cli.Command{
Flags: []cli.Flag{},
Action: func(context *cli.Context) error {
var (
ctx = contextpkg.Background()
ctx = background
args = []string(context.Args())
exitError error
)
cs, err := resolveContentStore(context)
conn, err := connectGRPC(context)
if err != nil {
return err
}
client := contentapi.NewContentClient(conn)
for _, arg := range args {
dgst, err := digest.Parse(arg)
if err != nil {
@ -39,11 +44,18 @@ var deleteCommand = cli.Command{
continue
}
if err := cs.Delete(dgst); err != nil {
if exitError == nil {
exitError = err
if _, err := client.Delete(ctx, &contentapi.DeleteContentRequest{
Digest: dgst,
}); err != nil {
switch grpc.Code(err) {
case codes.NotFound:
// if it is already deleted, ignore!
default:
if exitError == nil {
exitError = err
}
log.G(ctx).WithError(err).Errorf("could not delete %v", dgst)
}
log.G(ctx).WithError(err).Errorf("could not delete %v", dgst)
continue
}

View file

@ -81,7 +81,7 @@ func (cs *Store) Delete(dgst digest.Digest) error {
return err
}
return nil
return errNotFound
}
return nil

View file

@ -8,6 +8,7 @@ import (
api "github.com/docker/containerd/api/services/content"
"github.com/docker/containerd/content"
"github.com/docker/containerd/log"
"github.com/golang/protobuf/ptypes/empty"
digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
"golang.org/x/net/context"
@ -56,6 +57,18 @@ func (s *Service) Info(ctx context.Context, req *api.InfoRequest) (*api.InfoResp
}, 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())
}
return &empty.Empty{}, nil
}
func (s *Service) Read(req *api.ReadRequest, session api.Content_ReadServer) error {
if err := req.Digest.Validate(); err != nil {
return grpc.Errorf(codes.InvalidArgument, "%v: %v", req.Digest, err)