Skip to content

runtime: make task.Delete API retriable - #14020

Merged
mxpv merged 1 commit into
containerd:mainfrom
fuweid:retryable-delete-shim-api
Aug 27, 2026
Merged

mxpv merged 1 commit into
containerd:mainfrom
fuweid:retryable-delete-shim-api

Conversation

@fuweid

@fuweid fuweid commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

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

Copilot AI lite review requested due to automatic review settings August 24, 2026 00:05
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Aug 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 NotFound while 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.

Comment thread core/runtime/v2/task_manager.go Resolved
Copilot AI review requested due to automatic review settings August 24, 2026 15:49
@fuweid
fuweid force-pushed the retryable-delete-shim-api branch from 5fefee0 to b30e3b2 Compare August 24, 2026 15:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread core/runtime/v2/task_manager.go Resolved
@fuweid
fuweid force-pushed the retryable-delete-shim-api branch from b30e3b2 to f5a6a79 Compare August 24, 2026 20:24
Copilot AI review requested due to automatic review settings August 24, 2026 20:24
@fuweid fuweid added this to the 2.4 milestone Aug 24, 2026
@fuweid
fuweid force-pushed the retryable-delete-shim-api branch from f5a6a79 to cd6f3cb Compare August 24, 2026 20:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread core/runtime/v2/task_manager.go Resolved
Copilot AI review requested due to automatic review settings August 24, 2026 20:29
@fuweid
fuweid force-pushed the retryable-delete-shim-api branch from cd6f3cb to dcc20d9 Compare August 24, 2026 20:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@fuweid fuweid added the cherry-pick/2.3.x Change to be cherry picked to release/2.3 label Aug 25, 2026
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]>
@fuweid
fuweid force-pushed the retryable-delete-shim-api branch from dcc20d9 to 24dc690 Compare August 26, 2026 22:12
Copilot AI review requested due to automatic review settings August 26, 2026 22:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread core/runtime/v2/shim.go Resolved
@fuweid

fuweid commented Aug 26, 2026

Copy link
Copy Markdown
Member Author

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have test coverage for this scenario already?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we have. I can handle it in the followup. The test case will be like

  1. Create container A
  2. Create task A with customize mounts
  3. Delete but Deactivate failed
  4. Recreate task A

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Aug 27, 2026
@mxpv
mxpv added this pull request to the merge queue Aug 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 27, 2026
@mxpv
mxpv added this pull request to the merge queue Aug 27, 2026
Merged via the queue into containerd:main with commit a9eb76f Aug 27, 2026
55 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Aug 27, 2026
@fuweid
fuweid deleted the retryable-delete-shim-api branch September 5, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick/2.3.x Change to be cherry picked to release/2.3 size/L

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants