mirror of
https://github.com/containers/bootc.git
synced 2026-02-05 15:45:53 +01:00
composefs: Handle bootc status after a soft reboot
After a soft reboot the kernel cmdline doesn't change so we can't rely on the `composefs=` parameter in the cmdline. Instead, we check the source of the root mount point Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
This commit is contained in:
committed by
Pragyan Poudyal
parent
f9931d13e8
commit
33e3b745ad
@@ -2,6 +2,7 @@ use std::{io::Read, sync::OnceLock};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use bootc_kernel_cmdline::utf8::Cmdline;
|
||||
use bootc_mount::inspect_filesystem;
|
||||
use fn_error_context::context;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -86,7 +87,23 @@ pub(crate) fn composefs_booted() -> Result<Option<&'static ComposefsCmdline>> {
|
||||
};
|
||||
let Some(v) = kv.value() else { return Ok(None) };
|
||||
let v = ComposefsCmdline::new(v);
|
||||
let r = CACHED_DIGEST_VALUE.get_or_init(|| Some(v));
|
||||
|
||||
// Find the source of / mountpoint as the cmdline doesn't change on soft-reboot
|
||||
let root_mnt = inspect_filesystem("/".into())?;
|
||||
|
||||
// This is of the format composefs:<composefs_hash>
|
||||
let verity_from_mount_src = root_mnt
|
||||
.source
|
||||
.strip_prefix("composefs:")
|
||||
.ok_or_else(|| anyhow::anyhow!("Root not mounted using composefs"))?;
|
||||
|
||||
let r = if *verity_from_mount_src != *v.digest {
|
||||
// soft rebooted into another deployment
|
||||
CACHED_DIGEST_VALUE.get_or_init(|| Some(ComposefsCmdline::new(verity_from_mount_src)))
|
||||
} else {
|
||||
CACHED_DIGEST_VALUE.get_or_init(|| Some(v))
|
||||
};
|
||||
|
||||
Ok(r.as_ref())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user