Skip to content

Commit

Permalink
task delete: Closes task IO before waiting
Browse files Browse the repository at this point in the history
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 <cbelu@cloudbasesolutions.com>
(cherry picked from commit 55faa5e)
Signed-off-by: Daniel Canter <dcanter@microsoft.com>
  • Loading branch information
claudiubelu authored and dcantah committed Oct 15, 2021
1 parent cad8793 commit bf02a83
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/cri/io/helpers_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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
}

Expand Down
1 change: 1 addition & 0 deletions task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit bf02a83

Please sign in to comment.