1
0
mirror of https://github.com/containers/bootc.git synced 2026-02-05 06:45:13 +01:00

composefs-backend: Start finalize-staged service on update/switch

Rename service to bootc-finalize-staged

Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
Signed-off-by: Colin Walters <walters@verbum.org>
This commit is contained in:
Pragyan Poudyal
2025-10-08 11:36:16 +05:30
committed by Colin Walters
parent c5971caf62
commit a650e32716
7 changed files with 32 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ pub(crate) mod boot;
pub(crate) mod finalize;
pub(crate) mod repo;
pub(crate) mod rollback;
pub(crate) mod service;
pub(crate) mod state;
pub(crate) mod status;
pub(crate) mod switch;

View File

@@ -91,7 +91,7 @@ pub(crate) async fn pull_composefs_repo(
.await
.context("Pulling composefs repo")?;
tracing::info!("id: {}, verity: {}", hex::encode(id), verity.to_hex());
tracing::info!("ID: {}, Verity: {}", hex::encode(id), verity.to_hex());
let repo = open_composefs_repo(&rootfs_dir)?;
let mut fs: crate::store::ComposefsFilesystem =

View File

@@ -0,0 +1,22 @@
use anyhow::{Context, Result};
use fn_error_context::context;
use std::process::Command;
use crate::composefs_consts::BOOTC_FINALIZE_STAGED_SERVICE;
/// Starts the finaize staged service which will "unstage" the deployment
/// This is called before an upgrade or switch operation, as these create a staged
/// deployment
#[context("Starting finalize staged service")]
pub(crate) fn start_finalize_stated_svc() -> Result<()> {
let cmd_status = Command::new("systemctl")
.args(["start", "--quiet", BOOTC_FINALIZE_STAGED_SERVICE])
.status()
.context("Starting finalize service")?;
if !cmd_status.success() {
anyhow::bail!("systemctl exited with status {cmd_status}")
}
Ok(())
}

View File

@@ -6,6 +6,7 @@ use crate::{
bootc_composefs::{
boot::{setup_composefs_bls_boot, setup_composefs_uki_boot, BootSetupType, BootType},
repo::pull_composefs_repo,
service::start_finalize_stated_svc,
state::write_composefs_state,
status::composefs_deployment_status,
},
@@ -36,6 +37,8 @@ pub(crate) async fn switch_composefs(opts: SwitchOpts) -> Result<()> {
anyhow::bail!("Target image is undefined")
};
start_finalize_stated_svc()?;
let (repo, entries, id, fs) =
pull_composefs_repo(&target_imgref.transport, &target_imgref.image).await?;

View File

@@ -6,6 +6,7 @@ use crate::{
bootc_composefs::{
boot::{setup_composefs_bls_boot, setup_composefs_uki_boot, BootSetupType, BootType},
repo::pull_composefs_repo,
service::start_finalize_stated_svc,
state::write_composefs_state,
status::composefs_deployment_status,
},
@@ -14,12 +15,12 @@ use crate::{
#[context("Upgrading composefs")]
pub(crate) async fn upgrade_composefs(_opts: UpgradeOpts) -> Result<()> {
// TODO: IMPORTANT Have all the checks here that `bootc upgrade` has for an ostree booted system
let host = composefs_deployment_status()
.await
.context("Getting composefs deployment status")?;
start_finalize_stated_svc()?;
// TODO: IMPORTANT We need to check if any deployment is staged and get the image from that
let imgref = host
.spec

View File

@@ -36,3 +36,5 @@ pub(crate) const USER_CFG_STAGED: &str = "user.cfg.staged";
/// This is relative to the boot/efi directory
pub(crate) const TYPE1_ENT_PATH: &str = "loader/entries";
pub(crate) const TYPE1_ENT_PATH_STAGED: &str = "loader/entries.staged";
pub(crate) const BOOTC_FINALIZE_STAGED_SERVICE: &str = "bootc-finalize-staged.service";