Skip to content

Commit

Permalink
Return error on timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Adrian Samfira <[email protected]>
  • Loading branch information
gabriel-samfira committed Dec 22, 2021
1 parent 3a86ec0 commit e31f95a
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions cmd/containerd-shim-runhcs-v1/task_hcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,23 +585,25 @@ func (ht *hcsTask) DeleteExec(ctx context.Context, eid string) (int, uint32, tim
switch state := e.State(); state {
case shimExecStateCreated:
e.ForceExit(ctx, 0)
case shimExecStateExited:
// The task process may have already exited, and the status set to
// shimExecStateExited, but resources may still be in the process
// of being cleaned up. Wait for ht.closed to be closed. This signals
// that waitInitExit() has finished destroying container resources,
// and layers were umounted.
// If the shim exits before resources are cleaned up, those resources
// will remain locked and untracked, which leads to lingering sandboxes
// and container resources like base vhdx.
select {
case <-time.After(30 * time.Second):
log.G(ctx).Warning("timed out waiting for resource cleanup")
case <-ht.closed:
}
case shimExecStateRunning:
return 0, 0, time.Time{}, newExecInvalidStateError(ht.id, eid, state, "delete")
}

// The task process may have already exited, and the status set to
// shimExecStateExited, but resources may still be in the process
// of being cleaned up. Wait for ht.closed to be closed. This signals
// that waitInitExit() has finished destroying container resources,
// and layers were umounted.
// If the shim exits before resources are cleaned up, those resources
// will remain locked and untracked, which leads to lingering sandboxes
// and container resources like base vhdx.
select {
case <-time.After(30 * time.Second):
log.G(ctx).Error("timed out waiting for resource cleanup")
return 0, 0, time.Time{}, errors.Wrap(hcs.ErrTimeout, "waiting for container resource cleanup")
case <-ht.closed:
}

status := e.Status()
if eid != "" {
ht.execs.Delete(eid)
Expand Down

0 comments on commit e31f95a

Please sign in to comment.