Skip to content

cri: only unmount image volumes when mounting fails - #14143

Merged
fuweid merged 1 commit into
containerd:mainfrom
fuweid:follow-up-13542
Sep 10, 2026
Merged

fuweid merged 1 commit into
containerd:mainfrom
fuweid:follow-up-13542

Conversation

@fuweid

@fuweid fuweid commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Both image volumes and its activated mount objects are tied to sandbox lease. Removing the snapshot from defered cleanup may leave activated mount object referencing to missing snapshot.

Keep a successfully image volume mount even if a later step (subpath check) fails. Only roll back the mount when mount.All itself fails. Sandbox cleanup and GC will release the remaining resources.

Follow-up: #13542

cc @hsiangkao

Avoid leaking active mount objects on image volume subpath validation failure

Both image volumes and its activated mount objects are tied to sandbox
lease. Removing the snapshot from defered cleanup may leave activated
mount object referencing to missing snapshot.

Keep a successfully image volume mount even if a later step (subpath check)
fails. Only roll back the mount when mount.All itself fails. Sandbox cleanup
and GC will release the remaining resources.

Signed-off-by: Wei Fu <[email protected]>
Copilot AI lite review requested due to automatic review settings September 10, 2026 02:31
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Sep 10, 2026
@fuweid fuweid added this to the 2.4 milestone Sep 10, 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.

🟡 Changes recommended

The new unmount-on-mount.All-failure path can unmount a concurrently mounted target in race scenarios unless it re-checks mount state before rolling back.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adjusts CRI image volume mount rollback behavior to avoid tearing down successfully mounted image volumes when later validation (e.g., image subpath checks) fails, relying on sandbox cleanup/GC to release lease-tied resources.

Changes:

  • Changes mutateImageMount to stop unmounting/removing image volume resources on non-mount failures, and only unmount when mount.All fails.
  • Adds clarifying comments about snapshot/mount-manager activation lifetime and a TODO about serializing per-target mounts.
  • Adds an integration test to verify image volume snapshots remain reusable after a failed image-subpath attempt.
File summaries
File Description
internal/cri/server/container_image_mount.go Updates mount rollback logic to keep successfully mounted image volumes and their snapshots when later steps fail.
integration/image_volume_linux_test.go Adds coverage to ensure a failed subpath attempt doesn’t prevent subsequent successful image volume usage.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 181 to 186
if err := mount.All(mounts, target); err != nil {
if unmountErr := mount.UnmountAll(target, 0); unmountErr != nil {
log.G(ctx).WithError(unmountErr).Errorf("failed to unmount image volume component %q", target)
}
return fmt.Errorf("failed to mount image volume component %q: %w", target, err)
}
@dmcgowan dmcgowan moved this from Needs Triage to Review In Progress in Pull Request Review Sep 10, 2026
@fuweid
fuweid added this pull request to the merge queue Sep 10, 2026
Merged via the queue into containerd:main with commit d562810 Sep 10, 2026
96 of 98 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Sep 10, 2026
@fuweid
fuweid deleted the follow-up-13542 branch September 10, 2026 15:07
@fuweid fuweid added cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-pick/2.3.x Change to be cherry picked to release/2.3 cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch cherry-picked/2.3.x PR commits are cherry picked into release/2.3 branch and removed cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch cherry-pick/2.3.x Change to be cherry picked to release/2.3 labels Sep 11, 2026
@samuelkarp samuelkarp added impact/changelog area/cri Container Runtime Interface (CRI) and removed impact/changelog labels Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cri Container Runtime Interface (CRI) cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch cherry-picked/2.3.x PR commits are cherry picked into release/2.3 branch size/M

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants