-
Notifications
You must be signed in to change notification settings - Fork 285
Wait for waitInitExit() to return #1249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -536,8 +536,9 @@ func (ht *hcsTask) KillExec(ctx context.Context, eid string, signal uint32, all | |
| }).Warn("failed to kill exec in task") | ||
| } | ||
|
|
||
| // iterate all | ||
| return false | ||
| // Iterate all. Returning false stops the iteration. See: | ||
| // https://pkg.go.dev/sync#Map.Range | ||
| return true | ||
| }) | ||
| } | ||
| if signal == 0x9 && eid == "" && ht.host != nil { | ||
|
|
@@ -578,8 +579,9 @@ func (ht *hcsTask) DeleteExec(ctx context.Context, eid string) (int, uint32, tim | |
| ex.ForceExit(ctx, 1) | ||
| } | ||
|
|
||
| // iterate next | ||
| return false | ||
| // Iterate all. Returning false stops the iteration. See: | ||
| // https://pkg.go.dev/sync#Map.Range | ||
| return true | ||
| }) | ||
| } | ||
| switch state := e.State(); state { | ||
|
|
@@ -588,6 +590,41 @@ func (ht *hcsTask) DeleteExec(ctx context.Context, eid string) (int, uint32, tim | |
| case shimExecStateRunning: | ||
| return 0, 0, time.Time{}, newExecInvalidStateError(ht.id, eid, state, "delete") | ||
| } | ||
|
|
||
| if eid == "" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are cleaning up resources here when deleting the init task (since this triggers
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. Let me dig a bit deeper and see if the entire
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I updated the PR to remove the task object after successfully deleting the init exec: |
||
| // We are killing the init task, so we expect the container to be | ||
| // stopped after this. | ||
| // | ||
| // 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: | ||
| } | ||
|
|
||
| // The init task has now exited. A ForceExit() has already been sent to | ||
| // execs. Cleanup execs and continue. | ||
| ht.execs.Range(func(key, value interface{}) bool { | ||
| if key == "" { | ||
| // Iterate next. | ||
| return true | ||
| } | ||
| ht.execs.Delete(key) | ||
|
|
||
| // Iterate all. Returning false stops the iteration. See: | ||
| // https://pkg.go.dev/sync#Map.Range | ||
| return true | ||
| }) | ||
| } | ||
|
|
||
| status := e.Status() | ||
| if eid != "" { | ||
| ht.execs.Delete(eid) | ||
|
|
@@ -617,8 +654,9 @@ func (ht *hcsTask) Pids(ctx context.Context) ([]runhcsopts.ProcessDetails, error | |
| ex := value.(shimExec) | ||
| pidMap[ex.Pid()] = ex.ID() | ||
|
|
||
| // Iterate all | ||
| return false | ||
| // Iterate all. Returning false stops the iteration. See: | ||
| // https://pkg.go.dev/sync#Map.Range | ||
| return true | ||
| }) | ||
| pidMap[ht.init.Pid()] = ht.init.ID() | ||
|
|
||
|
|
@@ -699,8 +737,9 @@ func (ht *hcsTask) waitForHostExit() { | |
| ex := value.(shimExec) | ||
| ex.ForceExit(ctx, 1) | ||
|
|
||
| // iterate all | ||
| return false | ||
| // Iterate all. Returning false stops the iteration. See: | ||
| // https://pkg.go.dev/sync#Map.Range | ||
| return true | ||
| }) | ||
| ht.init.ForceExit(ctx, 1) | ||
| ht.closeHost(ctx) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.