check task existence before new task
make user know correct error when new task. Signed-off-by: Ace-Tang <aceapril@126.com>
This commit is contained in:
parent
f1a3a6fba6
commit
124194b98b
@ -173,11 +173,14 @@ func (l *local) Create(ctx context.Context, r *api.CreateTaskRequest, _ ...grpc.
|
|||||||
Options: m.Options,
|
Options: m.Options,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
runtime, err := l.getRuntime(container.Runtime.Name)
|
rtime, err := l.getRuntime(container.Runtime.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c, err := runtime.Create(ctx, r.ContainerID, opts)
|
if _, err := rtime.Get(ctx, r.ContainerID); err != runtime.ErrTaskNotExists {
|
||||||
|
return nil, errdefs.ToGRPC(fmt.Errorf("task %s already exists", r.ContainerID))
|
||||||
|
}
|
||||||
|
c, err := rtime.Create(ctx, r.ContainerID, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errdefs.ToGRPC(err)
|
return nil, errdefs.ToGRPC(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user