Repository navigation
cri: only unmount image volumes when mounting fails - #14143
Merged
Merged
Conversation
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]>
Contributor
There was a problem hiding this comment.
🟡 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
mutateImageMountto stop unmounting/removing image volume resources on non-mount failures, and only unmount whenmount.Allfails. - 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) | ||
| } |
hsiangkao
approved these changes
Sep 10, 2026
dmcgowan
approved these changes
Sep 10, 2026
This was referenced Sep 11, 2026
This was referenced Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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