Merge pull request #636 from stevvooe/rootfs-alreadyexists

services/rootfs: return grpc code on existence
This commit is contained in:
Michael Crosby 2017-03-16 15:02:10 -07:00 committed by GitHub
commit e8622f970d

View file

@ -15,6 +15,7 @@ import (
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"golang.org/x/net/context" "golang.org/x/net/context"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes"
) )
func init() { func init() {
@ -67,7 +68,7 @@ func (s *Service) Unpack(ctx context.Context, pr *rootfsapi.UnpackRequest) (*roo
func (s *Service) Prepare(ctx context.Context, ir *rootfsapi.PrepareRequest) (*rootfsapi.MountResponse, error) { func (s *Service) Prepare(ctx context.Context, ir *rootfsapi.PrepareRequest) (*rootfsapi.MountResponse, error) {
mounts, err := rootfs.InitRootFS(ctx, ir.Name, ir.ChainID, ir.Readonly, s.snapshotter, mounter{}) mounts, err := rootfs.InitRootFS(ctx, ir.Name, ir.ChainID, ir.Readonly, s.snapshotter, mounter{})
if err != nil { if err != nil {
return nil, err return nil, grpc.Errorf(codes.AlreadyExists, "%v", err)
} }
return &rootfsapi.MountResponse{ return &rootfsapi.MountResponse{
Mounts: apiMounts(mounts), Mounts: apiMounts(mounts),