Repository navigation
runtime: invoke Shutdown after every task deletion - #13958
Conversation
|
cc @mxpv |
There was a problem hiding this comment.
Pull request overview
This PR ensures containerd always invokes TaskService.Shutdown after deleting a task (including sandboxed task API v3 cases), so grouped shims reliably receive a shutdown request once the last active task is removed (e.g., when the pause container exits before other sandbox containers).
Changes:
- Always call
waitShutdown()fromshimTask.delete()(removing sandbox/API-version conditional behavior). - Update task deletion call sites to match the new
shimTask.deletesignature. - Add an integration test covering the “pause exits first” sandbox cleanup scenario.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| integration/issue7496_shutdown_linux_test.go | Adds an integration test to validate shim shutdown when the pause task exits before other sandbox containers. |
| core/runtime/v2/task_manager.go | Updates task deletion paths to use the new shimTask.delete signature and removes now-unused sandbox checks. |
| core/runtime/v2/shim.go | Makes shimTask.delete always invoke TaskService.Shutdown via waitShutdown(). |
| core/runtime/v2/shim_load.go | Updates leaked-shim cleanup path to use the new shimTask.delete signature. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
43f173e to
7b17061
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
integration/issue7496_shutdown_linux_test.go:128
- The post-RemovePodSandbox assertion is potentially racy/brittle: RemovePodSandbox doesn’t necessarily guarantee the shim has fully exited by the time it returns, so an immediate Connect() can transiently succeed (or fail with a different transport error than the exact string). Consider retrying until Connect fails within a bounded timeout instead of asserting a specific error substring on the first attempt.
t.Log("Shim should be shutdown")
_, err = shimCli.Connect(ctx, &apitask.ConnectRequest{})
require.Error(t, err)
require.ErrorContains(t, err, "ttrpc: closed")
}
7b17061 to
c4694a4
Compare
c4694a4 to
573a260
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (1)
core/runtime/v2/shim.go:581
waitShutdownis invoked with the caller context. If the Delete request context is already canceled/expired (a scenario called out in the issue discussion and the FIXME below),timeout.WithContext(ctx, …)will be canceled immediately and the Shutdown RPC won’t be delivered, which can still leave a leaky shim while the task is removed from the manager. Usecontext.WithoutCancel(ctx)(still bounded byshutdownTimeout) so a best-effort Shutdown is attempted even when the original request context is canceled.
if err := s.waitShutdown(ctx); err != nil {
// FIXME(fuweid):
//
// If the error is context canceled, should we use context.TODO()
// to wait for it?
log.G(ctx).WithField("id", s.ID()).WithError(err).Error("failed to shutdown shim task and the shim might be leaked")
573a260 to
e0f6f0f
Compare
e0f6f0f to
a84e6e4
Compare
TaskService.Shutdown may be invoked multiple times. A grouped shim itself does not terminate while it still has active tasks. It terminates only after receiving a Shutdown request when no active tasks remain. The shim manager should invoke TaskService.Shutdown after deleting every task, regardless of whether the task represents sandbox or not. This ensures that the shim receives Shutdown when the last active task is deleted. In CRI, the pause container uses oom_score_adj=-998, making it unlikely to be OOM-killed. However, it may still exit or be killed before the other containers in the sandbox. SandboxService.Shutdown and TaskService.Shutdown are independent APIs. Sandbox service should make sure there is no active containers before shutdown. So, for the task service, we should invoke Shutdown for each task. Removing the supportSandboxAPIVersion check does not change behavior for shims using task API versions below v3. Those shims were already forced down the non-sandboxed path and received Shutdown after every task deletion. The behavior change applies only to sandboxed tasks using task API v3, which now receive Shutdown after deletion as well. Signed-off-by: Wei Fu <[email protected]>
9bb9ef8 to
402eb31
Compare
|
/cherry-pick 2.3 |
|
@mxpv: cannot checkout DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@mxpv: cannot checkout DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/cherry-pick release/2.3 |
|
@mxpv: #13958 failed to apply on top of branch "release/2.0": DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@mxpv: new pull request created: #14636 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
TaskService.Shutdown may be invoked multiple times. A grouped shim itself does not terminate while it still has active tasks. It terminates only after receiving a Shutdown request when no active tasks remain.
The shim manager should invoke TaskService.Shutdown after deleting every task, regardless of whether the task represents sandbox or not. This ensures that the shim receives Shutdown when the last active task is deleted.
In CRI, the pause container uses oom_score_adj=-998, making it unlikely to be OOM-killed. However, it may still exit or be killed before the other containers in the sandbox. SandboxService.Shutdown and TaskService.Shutdown are independent APIs. Sandbox service should make sure there is no active containers before shutdown. So, for the task service, we should invoke Shutdown for each task.
Removing the supportSandboxAPIVersion check does not change behavior for shims using task API versions below v3. Those shims were already forced down the non-sandboxed path and received Shutdown after every task deletion. The behavior change applies only to sandboxed tasks using task API v3, which now receive Shutdown after deletion as well.
Part of #8981
REF: #6703