Close io after task deletion to avoid race condition.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
0273e970a4
commit
4ac4fd0b6a
5
task.go
5
task.go
@ -283,7 +283,6 @@ func (t *task) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStat
|
||||
if t.io != nil {
|
||||
t.io.Cancel()
|
||||
t.io.Wait()
|
||||
t.io.Close()
|
||||
}
|
||||
r, err := t.client.TaskService().Delete(ctx, &tasks.DeleteTaskRequest{
|
||||
ContainerID: t.id,
|
||||
@ -291,6 +290,10 @@ func (t *task) Delete(ctx context.Context, opts ...ProcessDeleteOpts) (*ExitStat
|
||||
if err != nil {
|
||||
return nil, errdefs.FromGRPC(err)
|
||||
}
|
||||
// Only cleanup the IO after a successful Delete
|
||||
if t.io != nil {
|
||||
t.io.Close()
|
||||
}
|
||||
return &ExitStatus{code: r.ExitStatus, exitedAt: r.ExitedAt}, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user