Skip to content

Commit

Permalink
fix the created tasks cannot be deleted
Browse files Browse the repository at this point in the history
Signed-off-by: Iceber Gu <[email protected]>
  • Loading branch information
Iceber committed Jul 8, 2024
1 parent 456c666 commit fee1ab3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/cmd/container/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,17 @@ func RemoveContainer(ctx context.Context, c containerd.Container, globalOptions
if err == nil {
<-es
}
case containerd.Created, containerd.Stopped:
// Created and stopped containers always get removed
case containerd.Created:
// TODO(Iceber): Since `containerd.WithProcessKill` blocks the killing of tasks with PID 0,
// remove the judgment and break when it is compatible with the tasks.
if task.Pid() == 0 {
// Created tasks with PID 0 always get removed
// Delete the task, without forcing kill
_, err = task.Delete(ctx)
return err
}
case containerd.Stopped:
// Stopped containers always get removed
// Delete the task, without forcing kill
_, err = task.Delete(ctx)
return err
Expand Down

0 comments on commit fee1ab3

Please sign in to comment.