Fix delete error code on the containerd daemon side.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
772aaf127a
commit
ffcb1cc9be
@ -91,9 +91,12 @@ func (t *Task) PID() uint32 {
|
|||||||
|
|
||||||
// Delete the task and return the exit status
|
// Delete the task and return the exit status
|
||||||
func (t *Task) Delete(ctx context.Context) (*runtime.Exit, error) {
|
func (t *Task) Delete(ctx context.Context) (*runtime.Exit, error) {
|
||||||
rsp, err := t.shim.Delete(ctx, empty)
|
rsp, shimErr := t.shim.Delete(ctx, empty)
|
||||||
if err != nil && !errdefs.IsNotFound(err) {
|
if shimErr != nil {
|
||||||
return nil, errdefs.FromGRPC(err)
|
shimErr = errdefs.FromGRPC(shimErr)
|
||||||
|
if !errdefs.IsNotFound(shimErr) {
|
||||||
|
return nil, shimErr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
t.tasks.Delete(ctx, t.id)
|
t.tasks.Delete(ctx, t.id)
|
||||||
if err := t.shim.KillShim(ctx); err != nil {
|
if err := t.shim.KillShim(ctx); err != nil {
|
||||||
@ -102,6 +105,9 @@ func (t *Task) Delete(ctx context.Context) (*runtime.Exit, error) {
|
|||||||
if err := t.bundle.Delete(); err != nil {
|
if err := t.bundle.Delete(); err != nil {
|
||||||
log.G(ctx).WithError(err).Error("failed to delete bundle")
|
log.G(ctx).WithError(err).Error("failed to delete bundle")
|
||||||
}
|
}
|
||||||
|
if shimErr != nil {
|
||||||
|
return nil, shimErr
|
||||||
|
}
|
||||||
t.events.Publish(ctx, runtime.TaskDeleteEventTopic, &eventstypes.TaskDelete{
|
t.events.Publish(ctx, runtime.TaskDeleteEventTopic, &eventstypes.TaskDelete{
|
||||||
ContainerID: t.id,
|
ContainerID: t.id,
|
||||||
ExitStatus: rsp.ExitStatus,
|
ExitStatus: rsp.ExitStatus,
|
||||||
|
@ -222,11 +222,14 @@ func (s *shim) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *shim) Delete(ctx context.Context) (*runtime.Exit, error) {
|
func (s *shim) Delete(ctx context.Context) (*runtime.Exit, error) {
|
||||||
response, err := s.task.Delete(ctx, &task.DeleteRequest{
|
response, shimErr := s.task.Delete(ctx, &task.DeleteRequest{
|
||||||
ID: s.ID(),
|
ID: s.ID(),
|
||||||
})
|
})
|
||||||
if err != nil && !errdefs.IsNotFound(err) {
|
if shimErr != nil {
|
||||||
return nil, errdefs.FromGRPC(err)
|
shimErr = errdefs.FromGRPC(shimErr)
|
||||||
|
if !errdefs.IsNotFound(shimErr) {
|
||||||
|
return nil, shimErr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// remove self from the runtime task list
|
// remove self from the runtime task list
|
||||||
// this seems dirty but it cleans up the API across runtimes, tasks, and the service
|
// this seems dirty but it cleans up the API across runtimes, tasks, and the service
|
||||||
@ -238,6 +241,9 @@ func (s *shim) Delete(ctx context.Context) (*runtime.Exit, error) {
|
|||||||
if err := s.bundle.Delete(); err != nil {
|
if err := s.bundle.Delete(); err != nil {
|
||||||
log.G(ctx).WithError(err).Error("failed to delete bundle")
|
log.G(ctx).WithError(err).Error("failed to delete bundle")
|
||||||
}
|
}
|
||||||
|
if shimErr != nil {
|
||||||
|
return nil, shimErr
|
||||||
|
}
|
||||||
return &runtime.Exit{
|
return &runtime.Exit{
|
||||||
Status: response.ExitStatus,
|
Status: response.ExitStatus,
|
||||||
Timestamp: response.ExitedAt,
|
Timestamp: response.ExitedAt,
|
||||||
|
@ -241,7 +241,7 @@ func (l *local) Delete(ctx context.Context, r *api.DeleteTaskRequest, _ ...grpc.
|
|||||||
}
|
}
|
||||||
exit, err := t.Delete(ctx)
|
exit, err := t.Delete(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errdefs.ToGRPC(err)
|
||||||
}
|
}
|
||||||
return &api.DeleteResponse{
|
return &api.DeleteResponse{
|
||||||
ExitStatus: exit.Status,
|
ExitStatus: exit.Status,
|
||||||
@ -257,7 +257,7 @@ func (l *local) DeleteProcess(ctx context.Context, r *api.DeleteProcessRequest,
|
|||||||
}
|
}
|
||||||
process, err := t.Process(ctx, r.ExecID)
|
process, err := t.Process(ctx, r.ExecID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, errdefs.ToGRPC(err)
|
||||||
}
|
}
|
||||||
exit, err := process.Delete(ctx)
|
exit, err := process.Delete(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user