-
Notifications
You must be signed in to change notification settings - Fork 168
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.
| let nextroot = run_dir | ||
| .open_dir_optional("nextroot") | ||
| .context("Opening nextroot")?; | ||
|
|
||
| let Some(nextroot) = nextroot else { | ||
| tracing::debug!("Nextroot is not a directory"); | ||
| println!("No deployment staged for soft rebooting"); | ||
| return Ok(()); | ||
| }; | ||
|
|
||
| let nextroot_mounted = nextroot | ||
| .is_mountpoint(".")? | ||
| .ok_or_else(|| anyhow::anyhow!("Failed to get mount info"))?; | ||
|
|
||
| if !nextroot_mounted { | ||
| tracing::debug!("Nextroot is not a mountpoint"); | ||
| println!("No deployment staged for soft rebooting"); | ||
| return Ok(()); | ||
| } | ||
|
|
||
| unmount(NEXTROOT, UnmountFlags::DETACH).context("Unmounting nextroot")?; | ||
|
|
||
| println!("Soft reboot state cleared successfully"); | ||
|
|
||
| Ok(()) |
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 logic to check for the existence and mount status of nextroot can be simplified to avoid code duplication and multiple return paths. This refactoring consolidates the checks into a single conditional block, making the function's control flow more straightforward and easier to maintain.
let nextroot = run_dir
.open_dir_optional("nextroot")
.context("Opening nextroot")?;
let mounted = match nextroot {
Some(nextroot) => {
let is_mounted = nextroot
.is_mountpoint(".")?
.ok_or_else(|| anyhow::anyhow!("Failed to get mount info"))?;
if !is_mounted {
tracing::debug!("Nextroot is not a mountpoint");
}
is_mounted
}
None => {
tracing::debug!("Nextroot is not a directory");
false
}
};
if mounted {
unmount(NEXTROOT, UnmountFlags::DETACH).context("Unmounting nextroot")?;
println!("Soft reboot state cleared successfully");
} else {
println!("No deployment staged for soft rebooting");
}
Ok(())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>
4e2eee6 to
0193cf9
Compare
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