Repository navigation
runtime: make task.Delete API retriable - #14020
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates runtime v2 task deletion to be safely retriable (especially when a shutdown attempt fails after the shim-side delete has already succeeded), while avoiding duplicate exit/delete event publication, and re-enables the previously-skipped integration test for this scenario.
Changes:
- Cache a successful shim-side task delete exit result on the shim instance so subsequent Delete retries can return the original exit after the shim reports
NotFound. - Adjust runtime v2 task manager delete flow to handle
NotFoundwhile still deactivating mounts best-effort. - Update the client/task Delete path to tolerate missing Status during delete cleanup and close IO on
NotFound; re-enable and strengthen the integration test assertion.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| integration/issue7496_shutdown_linux_test.go | Re-enables the shutdown-retry regression test and adds an assertion for the closed ttrpc connection error. |
| core/runtime/v2/task_manager.go | Changes Delete error handling to support retriable delete and ensure mount deactivation occurs in NotFound cases. |
| core/runtime/v2/shim.go | Adds per-shim cached delete exit state and uses it to make task Delete retriable without emitting duplicate events. |
| client/task.go | Allows Delete to proceed when Status is unavailable and closes IO when Delete returns NotFound. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
5fefee0 to
b30e3b2
Compare
b30e3b2 to
f5a6a79
Compare
f5a6a79 to
cd6f3cb
Compare
cd6f3cb to
dcc20d9
Compare
To make task.Delete retriable, this patch caches the delete result in memory after the shim successfully deletes the task. If a later shutdown attempt fails, a subsequent Delete retry can complete cleanup and return the cached exit information. If containerd restarts after deleting the task, the in-memory cache is lost, and containerd will publish TaskExit and TaskDelete events again to subscribers. Currently, the exit status returned by shim-delete is always 137. In a follow-up, containerd-shim-runc-v2 should store the actual exit status in the state directory, so that shim-delete can reuse it instead of returning a hard-coded value. Implements: containerd#8981 Signed-off-by: Wei Fu <[email protected]>
dcc20d9 to
24dc690
Compare
|
ping @samuelkarp @dmcgowan @mikebrow @mxpv @AkihiroSuda please take a look when you have chance. It took many years. Thanks |
| log.G(ctx).WithError(err).WithField("task", taskID).Errorf("failed to deactivate mounts") | ||
| // FIXME(fuweid): It seems that cleaning this up is best-effort because | ||
| // GC can guarantee that the mount is deleted when the container is deleted. | ||
| // What if we reuse the container and restart the task? |
There was a problem hiding this comment.
Do we have test coverage for this scenario already?
There was a problem hiding this comment.
I don't think we have. I can handle it in the followup. The test case will be like
- Create container A
- Create task A with customize mounts
- Delete but Deactivate failed
- Recreate task A
To make task.Delete retriable, this patch caches the delete result in
memory after the shim successfully deletes the task. If a later shutdown
attempt fails, a subsequent Delete retry can complete cleanup and return the
cached exit information.
If containerd restarts after deleting the task, the in-memory cache is lost,
and containerd will publish TaskExit and TaskDelete events again to
subscribers. Currently, the exit status returned by shim-delete is always
137. In a follow-up, containerd-shim-runc-v2 should store the actual exit
status in the state directory, so that shim-delete can reuse it instead of
returning a hard-coded value.
Implements: #8981