-
Notifications
You must be signed in to change notification settings - Fork 150
WIP: install: Handle mount points in rootfs operations #1727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| // Check if this entry is a directory | ||
| let etype = e.file_type()?; | ||
| if etype == FileType::dir() { | ||
| // Check if this directory is a mount point (separate filesystem) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offhand this seems sane to me
cgwalters
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could still land this with a test case or so?
Which I guess partially blocks on cleaning up the install test cases.
crates/ostree-ext/src/commit.rs
Outdated
| } | ||
| // Also ignore bind mounts, if we have a new enough kernel with statx() | ||
| // that will tell us. | ||
| // For mount points (e.g., separate LVM volumes under /var), we need to clean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the record I think this code is "almost" dead, it should only be reachable from the ostree container commit CLI verb which we have backed away from.
While it is related, I think this would be better as a separate PR with its own rationale, because it's really not related at all to the install flow.
|
I'm not quite sure this is going to actively fix #1728 though. This case is more like "system-reinstall-bootc on a system where e.g. |
When performing a to-filesystem installation, the target directory may contain pre-existing mount points for directories like /var, /var/lib/containers, etc. These are legitimate in hybrid/existing filesystem scenarios where certain directories are on separate partitions. This change enhances the empty rootdir check to: - Recursively detect directories that contain only mount points - Skip directories that are themselves mount points - Allow installation to proceed when mount hierarchies exist (e.g., /var containing /var/lib which contains mounted /var/lib/containers) Also adds integration test coverage for separate /var mount scenarios using LVM. Assisted-by: Claude Code (Sonnet 4.5) Signed-off-by: ckyrouac <ckyrouac@redhat.com>
| /// This handles cases like /var containing /var/lib (not a mount) which contains | ||
| /// /var/lib/containers (a mount point). | ||
| #[context("Checking if directory contains only mount points")] | ||
| fn dir_contains_only_mounts(parent_fd: &Dir, dir_name: &str) -> Result<bool> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could have a unit test for this for the trivial cases at least (no inner mounts). Actually testing the mount case needs an integration test.
| } | ||
|
|
||
| // There must be a boot directory (that is empty) | ||
| if name == BOOT { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might be able to consolidate this logic with the above?
| } | ||
|
|
||
| // Found a non-mount, non-directory-of-mounts entry | ||
| tracing::debug!("Found non-mount entry in {dir_name}: {entry_name}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logs here feel a bit noisy potentially, how about making this
fn require_dir_contains_only_mounts(...) -> Result<()> and the error message is the first non-mount entry?
Then I think we probably don't need the logs at all, the error will include the info.
| if dir_contains_only_mounts(rootfs_fd, &name)? { | ||
| tracing::debug!("Skipping directory containing only mount points: {name}"); | ||
| continue; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels a bit weird to me to fall through here on error instead of just erroring out, see above
Allow mount points (separate filesystems) to exist during to-filesystem installations by detecting and skipping them in the empty rootdir check.
When cleaning directories during install, recursively clean the contents of mount point directories while preserving the mount point itself. This is necessary for cases where subdirectories like /var/log or /var/home are separate logical volumes.
Assisted-by: Claude Code
Fixes #1728
I need to test this more and add automated tests. Looking for feedback on possible side effects I'm not aware of.