-
Notifications
You must be signed in to change notification settings - Fork 146
composefs/install: Copy /etc contents to state #1560
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
composefs/install: Copy /etc contents to state #1560
Conversation
|
I've started out by separating new composefs-backend related code to |
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.
Code Review
This pull request refactors the initramfs crate into a library and introduces functionality to copy /etc contents for composefs installations. The changes are logical and follow the PR's description. I've identified a couple of areas for improvement in the new copy_etc_to_state function concerning resource management and error handling, and a minor code style issue.
| use camino::Utf8PathBuf; | ||
| use fn_error_context::context; | ||
|
|
||
| use bootc_initramfs_setup; |
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.
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.
Done
99c2823 to
c5c3751
Compare
67c4e8d to
b45ef30
Compare
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.
Looks OK, can you just fix to use tempdir, the other bits can be followups
| if !output.status.success() { | ||
| anyhow::bail!( | ||
| "Copying /etc failed with status {}: {}", | ||
| output.status, | ||
| String::from_utf8_lossy(&output.stderr) | ||
| ); | ||
| } |
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.
We have a handy
bootc/crates/utils/src/command.rs
Line 38 in 7434b0f
| fn run_capture_stderr(&mut self) -> Result<()>; |
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 see. I'll use that
| let uuid = uuid::Uuid::new_v4(); | ||
| let dir = format!("/var/tmp/{uuid}"); | ||
|
|
||
| create_dir_all(&dir).context("Creating temp directory")?; |
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.
Confused why we wouldn't just use tempdir::tempdir
|
|
||
| create_dir_all(&dir).context("Creating temp directory")?; | ||
|
|
||
| bootc_initramfs_setup::mount_at_wrapper(composefs_fd, CWD, &dir)?; |
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.
Ah yeah, we have mount helper code in lib/...and in composefs-boot, probably again need to factor out a helper crate
|
|
||
| bootc_initramfs_setup::mount_at_wrapper(composefs_fd, CWD, &dir)?; | ||
|
|
||
| let output = Command::new("cp") |
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'm totally fine with this, but at some point I'd like to add a high level copy_recursive to e.g. cap-std-ext
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.
yes, that would be ideal
| ]) | ||
| .output()?; | ||
|
|
||
| // Unmount regardless of copy succeeding |
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.
Yeah I think what we want is a wrapper for tempdir that handles unmount-on-drop
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.
Composefs has a struct for exactly this, but again is only visible at crate level. We could make that public. https://github.com/containers/composefs-rs/blob/main/crates/composefs/src/mountcompat.rs#L129
The composefs-rs crate has a lot of helper functions which are private
c5c3751 to
2c6d88c
Compare
For bind mounting /etc we copy the contents of the EROFS' /etc to the deployment's state directory Mounting the EORFS requires help from the initramfs crate, so we also turn it into a library crate. Signed-off-by: Johan-Liebert1 <[email protected]>
2c6d88c to
1d8606c
Compare
For bind mounting /etc we copy the contents of the EROFS' /etc to the deployment's state directory
Mounting the EORFS requires help from the initramfs crate, so we also turn it into a library crate.