Skip to content

Commit b241b44

Browse files
committed
feat(rollback): add --apply flag
Adds an --apply flag to the `bootc rollback` command to implement automated restarts. Have confirmed this works by building the bootc binary and running `bootc rollback --apply` on my host. This restarted the machine into the new (rollback) image. Closes #1029 Signed-off-by: Robert Sturla <[email protected]>
1 parent b991a93 commit b241b44

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

docs/src/man/bootc-rollback.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ queued upgrade) then it will be discarded
77

88
# SYNOPSIS
99

10-
**bootc rollback** \[**-h**\|**\--help**\]
10+
**bootc rollback** \[**\--apply**\] \[**-h**\|**\--help**\]
1111

1212
# DESCRIPTION
1313

@@ -28,6 +28,14 @@ rollback invocation.
2828

2929
# OPTIONS
3030

31+
**\--apply**
32+
33+
: Restart or reboot into the rollback image.
34+
35+
Currently, this option always reboots. In the future this command
36+
will detect the case where no kernel changes are queued, and perform
37+
a userspace-only restart.
38+
3139
**-h**, **\--help**
3240

3341
: Print help (see a summary with -h)

lib/src/cli.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,15 @@ pub(crate) struct SwitchOpts {
131131

132132
/// Options controlling rollback
133133
#[derive(Debug, Parser, PartialEq, Eq)]
134-
pub(crate) struct RollbackOpts {}
134+
pub(crate) struct RollbackOpts {
135+
/// Restart or reboot into the rollback image.
136+
///
137+
/// Currently, this option always reboots. In the future this command
138+
/// will detect the case where no kernel changes are queued, and perform
139+
/// a userspace-only restart.
140+
#[clap(long)]
141+
pub(crate) apply: bool,
142+
}
135143

136144
/// Perform an edit operation
137145
#[derive(Debug, Parser, PartialEq, Eq)]
@@ -905,9 +913,15 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
905913

906914
/// Implementation of the `bootc rollback` CLI command.
907915
#[context("Rollback")]
908-
async fn rollback(_opts: RollbackOpts) -> Result<()> {
916+
async fn rollback(opts: RollbackOpts) -> Result<()> {
909917
let sysroot = &get_storage().await?;
910-
crate::deploy::rollback(sysroot).await
918+
crate::deploy::rollback(sysroot).await?;
919+
920+
if opts.apply {
921+
crate::reboot::reboot()?;
922+
}
923+
924+
Ok(())
911925
}
912926

913927
/// Implementation of the `bootc edit` CLI command.

0 commit comments

Comments
 (0)