-
Notifications
You must be signed in to change notification settings - Fork 169
Composefs changes #1915
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?
Composefs changes #1915
Conversation
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 introduces several enhancements to composefs functionality. It adds an option to reset the soft reboot state and modifies the soft reboot logic to align with the ostree API, where a soft reboot is only initiated if --apply is passed. Additionally, it updates the image digest query format to match recent changes in composefs-rs. The changes are well-structured and improve the consistency and usability of the soft reboot feature. My review includes a suggestion to refactor a part of the new reset_soft_reboot function to improve code clarity and maintainability.
0193cf9 to
364e600
Compare
|
Setting up boot components seem to be failing in centos9, f42 with |
|
I guess #1926 is related |
| const NEXTROOT: &str = "/run/nextroot"; | ||
|
|
||
| #[context("Resetting soft reboot state")] | ||
| fn reset_soft_reboot() -> 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 think functions like this should accept their global state, like Storage.
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 have an argument when they don't use it. We could use run from the Storage, but we need to bind mount /run from host any to unmount nextroot, unless I'm missing something here
|
|
||
| let Some(nextroot) = nextroot else { | ||
| tracing::debug!("Nextroot is not a directory"); | ||
| println!("No deployment staged for soft rebooting"); |
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.
Ideally we share these output messages between the two backends
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.
That would be great, but afaik the implementation for soft reboot for ostree backend is in the ostree repo and not bootc. In the ostree path, we don't print anything if there is no deployment staged for soft rebooting. I have updated the final messages, i.e. soft reboot prep complete and soft reboot state reset messages, to match the ostree ones
|
|
||
| if opts.soft_reboot.is_some() { | ||
| prepare_soft_reboot_composefs(storage, booted_cfs, &id.to_hex(), true).await?; | ||
| prepare_soft_reboot_composefs(storage, booted_cfs, Some(&id.to_hex()), true, false).await?; |
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.
Having more than one boolean value to functions I think leads to confusion as to what they mean. I think this can become an enum since they're mutually exclusive no?
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 this is from an older commit? I had changed this to an enum
364e600 to
ad5fa7f
Compare
Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Aligning with ostree API, now we only initiate soft-reboot if `--apply` is passed to `bootc update`, `bootc switch`, else we only prepare the soft reboot Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
After bootc/commit/49d753f996747a9b1f531abf35ba4e207cf4f020, composefs-rs saves config in the format `oci-config-sha256:`. Update to match the same Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
When `--download-only` is passed, only download the image into the composefs repository but don't finalize it. Conver the /run/composefs/staged-deployment to a JSON file and Add a finalization_locked field depending upon which the finalize service will either finalize the staged deployment or leave it as is for garbage collection (even though GC is not fully implemented right now). Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
ad5fa7f to
3793354
Compare
| // We want the digest in the form of "sha256:abc123" | ||
| let config_digest = format!("{}", imginfo.manifest.config().digest()); |
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.
Hmm isn't this us losing type safety in that basically composefs-rs is using a different type alias for digests than exists in https://docs.rs/oci-spec/latest/oci_spec/image/struct.Digest.html ?
I think we could probably impl From<oci_spec::Digest> for composefs_rs::Sha256Digest or so?
Having to go through strings is definitely a big trap.
| #[context("Resetting soft reboot state")] | ||
| pub(crate) fn reset_soft_reboot() -> Result<()> { | ||
| let run = Utf8Path::new("/run"); | ||
| bind_mount_from_pidns(PID1, &run, &run, true).context("Bind mounting /run")?; |
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 don't think this is necessary, we only need to do that when run under podman.
| .context("Opening nextroot")?; | ||
|
|
||
| let Some(nextroot) = nextroot else { | ||
| tracing::debug!("Nextroot is not a 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.
It doesn't exist, not just not a directory
| return Ok(()); | ||
| } | ||
|
|
||
| unmount(NEXTROOT, UnmountFlags::DETACH).context("Unmounting nextroot")?; |
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.
Does this work though? We always enter a mount namespace, so this is where...ohhhh, I see that's why you did the bind mount of /run from the host mountns above.
And indeed I think we have similar code in ostree.
But...hmmm I think it'd be cleaner to avoid mutating global state this way - we could fork a child process that does the umount (look at similar code in bind_mount_from_pidns) or we could always pull in the real /run right after we do the re-exec to enter a new mountns.
| storage: &Storage, | ||
| booted_cfs: &BootedComposefs, | ||
| deployment_id: &String, | ||
| deployment_id: Option<&String>, |
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.
Prefer Option<&str>
| } | ||
|
|
||
| #[derive(Debug, Serialize, Deserialize)] | ||
| pub(crate) struct StagedDeployment { |
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.
This one seems like it could use a comment
| .atomic_replace_with( | ||
| COMPOSEFS_STAGED_DEPLOYMENT_FNAME, | ||
| |f| -> std::io::Result<()> { | ||
| f.write_all(new_staged.to_canon_json_string()?.as_bytes()) |
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.
Doesn't matter here but we can optimize this by not serializing to an intermediate string by using the canon-json-rs formatter with serde_json::to_writer
Most of this is in prep for #1913
Add option to reset soft reboot state
Don't soft-reboot automatically
Aligning with ostree API, now we only initiate soft-reboot if
--applyis passed to
bootc update,bootc switch, else we only prepare thesoft reboot
Update image digest query format
After bootc/commit/49d753f996747a9b1f531abf35ba4e207cf4f020,
composefs-rs saves config in the format
oci-config-sha256:.Update to match the same
composefs/update: Handle --download-only flag
When
--download-onlyis passed, only download the image into thecomposefs repository but don't finalize it.
Conver the /run/composefs/staged-deployment to a JSON file and Add a
finalization_locked field depending upon which the finalize service will
either finalize the staged deployment or leave it as is for garbage
collection (even though GC is not fully implemented right now).
Some commits are split from #1913