Skip to content

Conversation

gursewak1997
Copy link
Contributor

Log key operations (deploy, upgrade, switch, install, etc.) to systemd journal with structured fields including image references, digests, and operation types. Uses existing journal infrastructure and follows ostree logging patterns.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces structured logging to the systemd journal for key bootc operations, which is a significant improvement for system observability. The changes are consistently applied across various commands like upgrade, switch, install, and deploy, using a common pattern with MESSAGE_IDs for easier log filtering. The logged fields are relevant and provide good context for each operation. I have one minor suggestion for improving consistency.

Copy link
Contributor

@bshephar bshephar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice improvement. It will be good to have these messages nicely in the Journal!

Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm largely OK with this as is, so marking approved. However one concern: We're not logging very much at all right now and I wonder how chatty this will feel in practice.

I think for example a no-op upgrade feels like it should log at most two messages:

  • Starting a check for updates
  • No updates found

I haven't looked if that's the case now.

In the changed image case it'd also be useful to take a look at how chatty it is. Offhand I think it'll be at least 5 messages? That's probably OK but still work looking at.

@gursewak1997 gursewak1997 force-pushed the bootc-1479 branch 3 times, most recently from 2735018 to 843e8fc Compare August 19, 2025 20:28
@cgwalters
Copy link
Collaborator

I looked at the test failures and did #1535 but not sure why this is just showing up now.

Comment on lines 281 to 285
const COMPLETION_JOURNAL_ID: &str = "0f9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4";
let msg = "Starting bootc installation completion";
crate::journal::journal_send(
Priority::Info,
msg,
[
("MESSAGE_ID", COMPLETION_JOURNAL_ID),
("BOOTC_STATEROOT", stateroot.unwrap_or("default")),
]
.into_iter(),
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm OK to merge as is but one thing that would help readability a good bit here is for us to have a wrapper macro like journal_send! that wraps the format! infrastructure.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And to go a bit more advanced, having it be something like

journal::message!(COMPLETION_JOURNAL_ID, "Starting installation completion", ...<other format args>).with(["BOOTC_STATEROOT", stateroot.unwrap_or("default")).send()

or so would look nicer, though definitely a bit more work to have the macro return a struct with methods etc.

Comment on lines 281 to 285
const COMPLETION_JOURNAL_ID: &str = "0f9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4";
let msg = "Starting bootc installation completion";
crate::journal::journal_send(
Priority::Info,
msg,
[
("MESSAGE_ID", COMPLETION_JOURNAL_ID),
("BOOTC_STATEROOT", stateroot.unwrap_or("default")),
]
.into_iter(),
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And to go a bit more advanced, having it be something like

journal::message!(COMPLETION_JOURNAL_ID, "Starting installation completion", ...<other format args>).with(["BOOTC_STATEROOT", stateroot.unwrap_or("default")).send()

or so would look nicer, though definitely a bit more work to have the macro return a struct with methods etc.

PreparedPullResult::Ready(prepared_image_meta) => {
// Log that we're pulling a new image
const PULL_JOURNAL_ID: &str = "5c4d3e2f1a0b9c8d7e6f5a4b3c2d1e0f9";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why duplicate this const? Though it does seem to me that "no changes" and "pulling a new image" are different events

}
}

// Fall back to the previous setup if journald isn't available
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm interesting...this would be a pretty big workflow change for those who are used to doing e.g. env RUST_LOG=trace bootc ...

I wonder if we can set things up so that we log to the journal always for key messages, but still use stdout/stderr for debug/trace level?

@gursewak1997 gursewak1997 force-pushed the bootc-1479 branch 3 times, most recently from 2b95e42 to c060bad Compare August 26, 2025 19:14
@gursewak1997 gursewak1997 requested a review from cgwalters August 27, 2025 18:45
Copy link
Collaborator

@cgwalters cgwalters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is looking a lot nicer, wouldn't you agree? I just have one outstanding comment

// Always try to use journald subscriber if we're running under systemd
// This ensures key messages (info, warn, error) go to the journal
let journald_layer = if let Ok(()) = std::env::var("JOURNAL_STREAM").map(|_| ()) {
tracing_journald::layer().ok()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want to have a filter here so that only info and above goes to the journal, right? I think it's possible with https://docs.rs/tracing-subscriber/latest/tracing_subscriber/layer/trait.Layer.html#method.with_filter - I can take a look if you want.

Otherwise someone debugging with e.g. env RUST_LOG=trace will completely spam the journal.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically same as this #1522 (comment)

@gursewak1997 gursewak1997 force-pushed the bootc-1479 branch 2 times, most recently from b539d00 to f365b70 Compare August 28, 2025 18:38
@cgwalters
Copy link
Collaborator

Ah looks like this needs a rebase now

@gursewak1997 gursewak1997 force-pushed the bootc-1479 branch 2 times, most recently from d925b62 to 137b7d8 Compare August 29, 2025 18:33
@cgwalters cgwalters enabled auto-merge August 29, 2025 19:49
@cgwalters cgwalters merged commit 64fcb08 into bootc-dev:main Aug 29, 2025
25 of 27 checks passed
@gursewak1997 gursewak1997 deleted the bootc-1479 branch August 29, 2025 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

log state transitions to systemd
3 participants