Skip to content

Commit ebe252c

Browse files
composefs-backend: Start finalize-staged service on update/switch
Signed-off-by: Pragyan Poudyal <[email protected]>
1 parent faa68a7 commit ebe252c

File tree

6 files changed

+32
-3
lines changed

6 files changed

+32
-3
lines changed

crates/lib/src/bootc_composefs/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pub(crate) mod boot;
22
pub(crate) mod finalize;
33
pub(crate) mod repo;
44
pub(crate) mod rollback;
5+
pub(crate) mod service;
56
pub(crate) mod state;
67
pub(crate) mod status;
78
pub(crate) mod switch;

crates/lib/src/bootc_composefs/repo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub(crate) async fn pull_composefs_repo(
9595
.await
9696
.context("Pulling composefs repo")?;
9797

98-
tracing::info!("id: {}, verity: {}", hex::encode(id), verity.to_hex());
98+
tracing::info!("ID: {}, Verity: {}", hex::encode(id), verity.to_hex());
9999

100100
let repo = open_composefs_repo(&rootfs_dir)?;
101101
let mut fs = create_composefs_filesystem(&repo, &hex::encode(id), None)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use anyhow::{Context, Result};
2+
use fn_error_context::context;
3+
use std::process::Command;
4+
5+
use crate::composefs_consts::COMPOSEFS_FINALIZE_STAGED_SERVICE;
6+
7+
/// Starts the finaize staged service which will "unstage" the deployment
8+
/// This is called before an upgrade or switch operation, as these create a staged
9+
/// deployment
10+
#[context("Starting finalize staged service")]
11+
pub(crate) fn start_finalize_stated_svc() -> Result<()> {
12+
let cmd_status = Command::new("systemctl")
13+
.args(["start", "--quiet", COMPOSEFS_FINALIZE_STAGED_SERVICE])
14+
.status()
15+
.context("Starting finalize service")?;
16+
17+
if !cmd_status.success() {
18+
anyhow::bail!("systemctl exited with status {cmd_status}")
19+
}
20+
21+
Ok(())
22+
}

crates/lib/src/bootc_composefs/switch.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{
66
bootc_composefs::{
77
boot::{setup_composefs_bls_boot, setup_composefs_uki_boot, BootSetupType, BootType},
88
repo::pull_composefs_repo,
9+
service::start_finalize_stated_svc,
910
state::write_composefs_state,
1011
status::composefs_deployment_status,
1112
},
@@ -36,6 +37,8 @@ pub(crate) async fn switch_composefs(opts: SwitchOpts) -> Result<()> {
3637
anyhow::bail!("Target image is undefined")
3738
};
3839

40+
start_finalize_stated_svc()?;
41+
3942
let (repo, entries, id, fs) =
4043
pull_composefs_repo(&target_imgref.transport, &target_imgref.image).await?;
4144

crates/lib/src/bootc_composefs/update.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{
66
bootc_composefs::{
77
boot::{setup_composefs_bls_boot, setup_composefs_uki_boot, BootSetupType, BootType},
88
repo::pull_composefs_repo,
9+
service::start_finalize_stated_svc,
910
state::write_composefs_state,
1011
status::composefs_deployment_status,
1112
},
@@ -14,12 +15,12 @@ use crate::{
1415

1516
#[context("Upgrading composefs")]
1617
pub(crate) async fn upgrade_composefs(_opts: UpgradeOpts) -> Result<()> {
17-
// TODO: IMPORTANT Have all the checks here that `bootc upgrade` has for an ostree booted system
18-
1918
let host = composefs_deployment_status()
2019
.await
2120
.context("Getting composefs deployment status")?;
2221

22+
start_finalize_stated_svc()?;
23+
2324
// TODO: IMPORTANT We need to check if any deployment is staged and get the image from that
2425
let imgref = host
2526
.spec

crates/lib/src/composefs_consts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,5 @@ pub(crate) const USER_CFG_STAGED: &str = "user.cfg.staged";
3636
/// This is relative to the boot/efi directory
3737
pub(crate) const TYPE1_ENT_PATH: &str = "loader/entries";
3838
pub(crate) const TYPE1_ENT_PATH_STAGED: &str = "loader/entries.staged";
39+
40+
pub(crate) const COMPOSEFS_FINALIZE_STAGED_SERVICE: &str = "composefs-finalize-staged.service";

0 commit comments

Comments
 (0)