Merge pull request #8643 from laurazard/io-close-before-cancel
task: don't `close()` io before `cancel()`
This commit is contained in:
commit
67349c1141
11
task.go
11
task.go
@ -325,7 +325,16 @@ func (t *task) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStat
|
|||||||
return nil, fmt.Errorf("task must be stopped before deletion: %s: %w", status.Status, errdefs.ErrFailedPrecondition)
|
return nil, fmt.Errorf("task must be stopped before deletion: %s: %w", status.Status, errdefs.ErrFailedPrecondition)
|
||||||
}
|
}
|
||||||
if t.io != nil {
|
if t.io != nil {
|
||||||
t.io.Close()
|
// io.Wait locks for restored tasks on Windows unless we call
|
||||||
|
// io.Close first (https://github.com/containerd/containerd/issues/5621)
|
||||||
|
// in other cases, preserve the contract and let IO finish before closing
|
||||||
|
if t.client.runtime == fmt.Sprintf("%s.%s", plugin.RuntimePlugin, "windows") {
|
||||||
|
t.io.Close()
|
||||||
|
}
|
||||||
|
// io.Cancel is used to cancel the io goroutine while it is in
|
||||||
|
// fifo-opening state. It does not stop the pipes since these
|
||||||
|
// should be closed on the shim's side, otherwise we might lose
|
||||||
|
// data from the container!
|
||||||
t.io.Cancel()
|
t.io.Cancel()
|
||||||
t.io.Wait()
|
t.io.Wait()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user