From 55faa5e93d7fdacc7d9b28ee79a0972ec18e3471 Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Sat, 4 Sep 2021 13:37:46 -0700 Subject: [PATCH] task delete: Closes task IO before waiting After containerd restarts, it will try to recover its sandboxes, containers, and images. If it detects a task in the Created or Stopped state, it will be removed. This will cause the containerd process it hang on Windows on the t.io.Wait() call. Calling t.io.Close() beforehand will solve this issue. Additionally, the same issue occurs when trying to stopp a sandbox after containerd restarts. This will solve that case as well. Signed-off-by: Claudiu Belu --- pkg/cri/io/helpers_windows.go | 4 ++++ task.go | 1 + 2 files changed, 5 insertions(+) diff --git a/pkg/cri/io/helpers_windows.go b/pkg/cri/io/helpers_windows.go index c4f9e449f..1dbb1aa61 100644 --- a/pkg/cri/io/helpers_windows.go +++ b/pkg/cri/io/helpers_windows.go @@ -50,6 +50,10 @@ func openPipe(ctx context.Context, fn string, flag int, perm os.FileMode) (io.Re } p.con = c }() + go func() { + <-ctx.Done() + p.Close() + }() return p, nil } diff --git a/task.go b/task.go index ab7f9f0a8..4e23fb861 100644 --- a/task.go +++ b/task.go @@ -315,6 +315,7 @@ func (t *task) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStat return nil, errors.Wrapf(errdefs.ErrFailedPrecondition, "task must be stopped before deletion: %s", status.Status) } if t.io != nil { + t.io.Close() t.io.Cancel() t.io.Wait() }