Skip to content

Commit

Permalink
allow client to remove created tasks with PID 0
Browse files Browse the repository at this point in the history
Fixes #7357

If a container is restored from a checkpoint that has a configuration
error, the task for the restored container is created, but fails to
start and is left in the state CREATED with a PID of 0. Before this
change, the only way to remove this task was to find the PID of the shim
monitoring the task and kill that process. Now, ctr t rm <task> will
work on tasks that result in the CREATED state with PID 0.

Signed-off-by: Gavin Inglis <giinglis@amazon.com>
  • Loading branch information
ginglis13 committed Dec 8, 2022
1 parent e1abaeb commit 80839f1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions task.go
Expand Up @@ -311,6 +311,11 @@ func (t *task) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStat
// On windows Created is akin to Stopped
break
}
if t.pid == 0 {
// allow for deletion of created tasks with PID 0
// https://github.com/containerd/containerd/issues/7357
break
}
fallthrough
default:
return nil, fmt.Errorf("task must be stopped before deletion: %s: %w", status.Status, errdefs.ErrFailedPrecondition)
Expand Down

0 comments on commit 80839f1

Please sign in to comment.