-
Notifications
You must be signed in to change notification settings - Fork 124
lib: add support for soft-reboots #1392
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
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 adds support for soft-reboots. The implementation has code duplication in lib/src/cli.rs
and lib/src/status.rs
. An unnecessary backup file (lib/src/status.rs.orig
) has been included and must be removed.
lib/src/cli.rs
Outdated
if can_soft_reboot { | ||
println!("Staged deployment is soft-reboot capable, performing soft-reboot..."); | ||
|
||
// Find the index of the staged deployment | ||
let deployments_list = sysroot.deployments(); | ||
let staged_index = deployments_list | ||
.iter() | ||
.position(|d| d.is_staged()) | ||
.ok_or_else(|| anyhow::anyhow!("Failed to find staged deployment index"))?; | ||
|
||
// Prepare the soft-reboot using ostree admin prepare-soft-reboot | ||
let mut cmd = std::process::Command::new("ostree"); | ||
cmd.args(["admin", "prepare-soft-reboot", &staged_index.to_string()]); | ||
let status = cmd.status().context("Failed to run ostree admin prepare-soft-reboot")?; | ||
if !status.success() { | ||
anyhow::bail!("ostree admin prepare-soft-reboot failed"); | ||
} | ||
|
||
// Perform the soft-reboot | ||
crate::reboot::soft_reboot()?; | ||
} else { | ||
crate::reboot::reboot()?; | ||
} |
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.
lib/src/cli.rs
Outdated
// Prepare the soft-reboot using ostree admin prepare-soft-reboot | ||
let mut cmd = std::process::Command::new("ostree"); | ||
cmd.args(["admin", "prepare-soft-reboot", &target_index.to_string()]); | ||
let status = cmd.status().context("Failed to run ostree admin prepare-soft-reboot")?; | ||
if !status.success() { | ||
anyhow::bail!("ostree admin prepare-soft-reboot failed"); | ||
} | ||
|
||
// Perform the soft-reboot | ||
crate::reboot::soft_reboot()?; |
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.
lib/src/status.rs
Outdated
if entry.soft_reboot_capable { | ||
write_row_name(&mut out, "Soft-reboot", prefix_len)?; | ||
writeln!(out, "capable")?; | ||
} |
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.
removed for now will be added with --verbose on #1399
f063416
to
825778d
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.
Looking good in general!
lib/src/cli.rs
Outdated
let deployments_list = sysroot.deployments(); | ||
let staged_deployment = deployments_list | ||
.iter() | ||
.find(|d| d.is_staged()) |
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 what we need to do at the moment, the code is fine.
However just looking at things overall, we should probably try to refactor in the future so that we have a clear staged state that has both the status object and the deployment and we shouldn't then need the unwrap_or
and error checking here.
521dd3a
to
408dbd9
Compare
Co-authored-by: Colin Walters <[email protected]> Signed-off-by: Joseph Marrero Corchado <[email protected]>
crate::deploy::rollback(sysroot).await?; | ||
|
||
if can_soft_reboot { | ||
soft_reboot_rollback(sysroot)?; |
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.
Since this function is only called once so it could be inlined, but OK as is
Moving to draft since this is blocked until we either:
|
That said one thing that would be cool would be us keeping cached container images for PRs on In this PR (actually the dependency one) we could explicitly bump the ostree version even before it's shipped $everywhere. |
depends on ostreedev/ostree#3455