Skip to content

Commit e42d10d

Browse files
Johan-Liebert1cgwalters
authored andcommitted
composefs: Add structured logging
Similar to the ostree install path, log the main operations install/switch/update/finalize with a unique journal id Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
1 parent 6f72ac2 commit e42d10d

9 files changed

Lines changed: 118 additions & 11 deletions

File tree

crates/lib/src/bootc_composefs/boot.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,16 @@ pub(crate) async fn setup_composefs_boot(
12241224
image_id: &str,
12251225
allow_missing_fsverity: bool,
12261226
) -> Result<()> {
1227+
const COMPOSEFS_BOOT_SETUP_JOURNAL_ID: &str = "1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5";
1228+
1229+
tracing::info!(
1230+
message_id = COMPOSEFS_BOOT_SETUP_JOURNAL_ID,
1231+
bootc.operation = "boot_setup",
1232+
bootc.image_id = image_id,
1233+
bootc.allow_missing_fsverity = allow_missing_fsverity,
1234+
"Setting up composefs boot",
1235+
);
1236+
12271237
let mut repo = open_composefs_repo(&root_setup.physical_root)?;
12281238
repo.set_insecure(allow_missing_fsverity);
12291239

crates/lib/src/bootc_composefs/delete.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,17 @@ pub(crate) async fn delete_composefs_deployment(
315315
storage: &Storage,
316316
booted_cfs: &BootedComposefs,
317317
) -> Result<()> {
318+
const COMPOSEFS_DELETE_JOURNAL_ID: &str = "2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7d6";
319+
320+
tracing::info!(
321+
message_id = COMPOSEFS_DELETE_JOURNAL_ID,
322+
bootc.operation = "delete",
323+
bootc.current_deployment = booted_cfs.cmdline.digest,
324+
bootc.target_deployment = deployment_id,
325+
"Starting composefs deployment deletion for {}",
326+
deployment_id
327+
);
328+
318329
let host = get_composefs_status(storage, booted_cfs).await?;
319330

320331
let booted = host.require_composefs_booted()?;

crates/lib/src/bootc_composefs/finalize.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,35 @@ pub(crate) async fn composefs_backend_finalize(
5252
storage: &Storage,
5353
booted_cfs: &BootedComposefs,
5454
) -> Result<()> {
55+
const COMPOSEFS_FINALIZE_JOURNAL_ID: &str = "0e9d8c7b6a5f4e3d2c1b0a9f8e7d6c5b4";
56+
57+
tracing::info!(
58+
message_id = COMPOSEFS_FINALIZE_JOURNAL_ID,
59+
bootc.operation = "finalize",
60+
bootc.current_deployment = booted_cfs.cmdline.digest,
61+
"Starting composefs staged deployment finalization"
62+
);
63+
5564
let host = get_composefs_status(storage, booted_cfs).await?;
5665

5766
let booted_composefs = host.require_composefs_booted()?;
5867

5968
let Some(staged_depl) = host.status.staged.as_ref() else {
60-
tracing::debug!("No staged deployment found");
69+
tracing::info!(
70+
message_id = COMPOSEFS_FINALIZE_JOURNAL_ID,
71+
bootc.operation = "finalize",
72+
"No staged deployment found"
73+
);
6174
return Ok(());
6275
};
6376

6477
if staged_depl.download_only {
65-
tracing::debug!("Staged deployment is marked download only. Won't finalize");
78+
tracing::info!(
79+
message_id = COMPOSEFS_FINALIZE_JOURNAL_ID,
80+
bootc.operation = "finalize",
81+
bootc.download_only = "true",
82+
"Staged deployment is marked download only. Won't finalize"
83+
);
6684
return Ok(());
6785
}
6886

crates/lib/src/bootc_composefs/gc.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@ pub(crate) fn gc_objects(sysroot: &Dir) -> Result<()> {
166166
/// perform GC
167167
#[fn_error_context::context("Running composefs garbage collection")]
168168
pub(crate) async fn composefs_gc(storage: &Storage, booted_cfs: &BootedComposefs) -> Result<()> {
169+
const COMPOSEFS_GC_JOURNAL_ID: &str = "3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8e7";
170+
171+
tracing::info!(
172+
message_id = COMPOSEFS_GC_JOURNAL_ID,
173+
bootc.operation = "gc",
174+
bootc.current_deployment = booted_cfs.cmdline.digest,
175+
"Starting composefs garbage collection"
176+
);
177+
169178
let host = get_composefs_status(storage, booted_cfs).await?;
170179
let booted_cfs_status = host.require_composefs_booted()?;
171180

crates/lib/src/bootc_composefs/repo.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,22 @@ pub(crate) async fn initialize_composefs_repository(
2525
root_setup: &RootSetup,
2626
allow_missing_fsverity: bool,
2727
) -> Result<(String, impl FsVerityHashValue)> {
28+
const COMPOSEFS_REPO_INIT_JOURNAL_ID: &str = "5d4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9";
29+
2830
let rootfs_dir = &root_setup.physical_root;
31+
let image_name = &state.source.imageref.name;
32+
let transport = &state.source.imageref.transport;
33+
34+
tracing::info!(
35+
message_id = COMPOSEFS_REPO_INIT_JOURNAL_ID,
36+
bootc.operation = "repository_init",
37+
bootc.source_image = %image_name,
38+
bootc.transport = %transport,
39+
bootc.allow_missing_fsverity = allow_missing_fsverity,
40+
"Initializing composefs repository for image {}:{}",
41+
transport,
42+
image_name
43+
);
2944

3045
crate::store::ensure_composefs_dir(rootfs_dir)?;
3146

@@ -80,6 +95,19 @@ pub(crate) async fn pull_composefs_repo(
8095
Sha512HashValue,
8196
crate::store::ComposefsFilesystem,
8297
)> {
98+
const COMPOSEFS_PULL_JOURNAL_ID: &str = "4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8";
99+
100+
tracing::info!(
101+
message_id = COMPOSEFS_PULL_JOURNAL_ID,
102+
bootc.operation = "pull",
103+
bootc.source_image = image,
104+
bootc.transport = transport,
105+
bootc.allow_missing_fsverity = allow_missing_fsverity,
106+
"Pulling composefs image {}:{}",
107+
transport,
108+
image
109+
);
110+
83111
let rootfs_dir = Dir::open_ambient_dir("/sysroot", ambient_authority())?;
84112

85113
let mut repo = open_composefs_repo(&rootfs_dir).context("Opening composefs repo")?;
@@ -93,7 +121,12 @@ pub(crate) async fn pull_composefs_repo(
93121
.await
94122
.context("Pulling composefs repo")?;
95123

96-
tracing::info!("ID: {id}, Verity: {}", verity.to_hex());
124+
tracing::info!(
125+
message_id = COMPOSEFS_PULL_JOURNAL_ID,
126+
id = id,
127+
verity = verity.to_hex(),
128+
"Pulled image into repository"
129+
);
97130

98131
let mut repo = open_composefs_repo(&rootfs_dir)?;
99132
repo.set_insecure(allow_missing_fsverity);

crates/lib/src/bootc_composefs/rollback.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,14 @@ pub(crate) async fn composefs_rollback(
186186
storage: &Storage,
187187
booted_cfs: &BootedComposefs,
188188
) -> Result<()> {
189+
const COMPOSEFS_ROLLBACK_JOURNAL_ID: &str = "6f5e4d3c2b1a0f9e8d7c6b5a4e3d2c1b0";
190+
191+
tracing::info!(
192+
message_id = COMPOSEFS_ROLLBACK_JOURNAL_ID,
193+
bootc.operation = "rollback",
194+
"Starting composefs rollback operation"
195+
);
196+
189197
let host = get_composefs_status(storage, booted_cfs).await?;
190198

191199
let new_spec = {

crates/lib/src/bootc_composefs/switch.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ pub(crate) async fn switch_composefs(
1818
booted_cfs: &BootedComposefs,
1919
) -> Result<()> {
2020
let target = imgref_for_switch(&opts)?;
21-
// TODO: Handle in-place
2221

22+
// TODO: Handle in-place
2323
let host = get_composefs_status(storage, booted_cfs)
2424
.await
2525
.context("Getting composefs deployment status")?;
@@ -39,6 +39,16 @@ pub(crate) async fn switch_composefs(
3939
anyhow::bail!("Target image is undefined")
4040
};
4141

42+
const COMPOSEFS_SWITCH_JOURNAL_ID: &str = "7a6b5c4d3e2f1a0b9c8d7e6f5a4b3c2d1";
43+
44+
tracing::info!(
45+
message_id = COMPOSEFS_SWITCH_JOURNAL_ID,
46+
bootc.operation = "switch",
47+
bootc.target_image = target_imgref.to_string(),
48+
bootc.apply_mode = opts.apply,
49+
"Starting composefs switch operation",
50+
);
51+
4252
let repo = &*booted_cfs.repo;
4353
let (image, img_config) = is_image_pulled(repo, &target_imgref).await?;
4454

crates/lib/src/bootc_composefs/update.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,17 @@ pub(crate) async fn upgrade_composefs(
311311
storage: &Storage,
312312
composefs: &BootedComposefs,
313313
) -> Result<()> {
314+
const COMPOSEFS_UPGRADE_JOURNAL_ID: &str = "9c8d7f6e5a4b3c2d1e0f9a8b7c6d5e4f3";
315+
316+
tracing::info!(
317+
message_id = COMPOSEFS_UPGRADE_JOURNAL_ID,
318+
bootc.operation = "upgrade",
319+
bootc.apply_mode = opts.apply,
320+
bootc.download_only = opts.download_only,
321+
bootc.from_downloaded = opts.from_downloaded,
322+
"Starting composefs upgrade operation"
323+
);
324+
314325
let host = get_composefs_status(storage, composefs)
315326
.await
316327
.context("Getting composefs deployment status")?;

crates/lib/src/install.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,13 +1704,10 @@ async fn prepare_install(
17041704
if composefs_options.composefs_backend && !composefs_options.allow_missing_verity && !is_uki {
17051705
composefs_options.allow_missing_verity = !root_filesystem.supports_fsverity();
17061706

1707-
tracing::debug!(
1708-
"Missing fsverity {}",
1709-
if composefs_options.allow_missing_verity {
1710-
"allowed"
1711-
} else {
1712-
"not allowed"
1713-
}
1707+
tracing::info!(
1708+
allow_missing_fsverity = composefs_options.allow_missing_verity,
1709+
uki = is_uki,
1710+
"ComposeFS install prep",
17141711
);
17151712
}
17161713

0 commit comments

Comments
 (0)