task service: return known error type

Found this error in a docker daemon log classified as an "uknown" error.
Since we know what this is return the correct error type so it can be
handled.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
Brian Goff 2021-10-01 17:45:51 +00:00
parent f6c1e7ed8b
commit 02e77bcdc1

View File

@ -210,7 +210,7 @@ func (l *local) Create(ctx context.Context, r *api.CreateTaskRequest, _ ...grpc.
return nil, errdefs.ToGRPC(err) return nil, errdefs.ToGRPC(err)
} }
if err == nil { if err == nil {
return nil, errdefs.ToGRPC(fmt.Errorf("task %s already exists", r.ContainerID)) return nil, errdefs.ToGRPC(fmt.Errorf("task %s: %w", r.ContainerID, errdefs.ErrAlreadyExists))
} }
c, err := rtime.Create(ctx, r.ContainerID, opts) c, err := rtime.Create(ctx, r.ContainerID, opts)
if err != nil { if err != nil {