Skip to content

status: Prep work for https://github.com/bootc-dev/bootc/pull/1285 #1291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lib/src/status.rs
Copy link
Contributor

@p5 p5 Apr 28, 2025

Choose a reason for hiding this comment

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

I've quickly changed a local version of #1285 to use the changes in this PR, and it now looks much cleaner.

Although this still doesn't allow us to access data stored within the HostStatus objects, which would be needed for displaying the /usr overlay status (#1258).
Unless you're thinking that can also be moved to be stored under BootEntry? Or am I completely overthinking the implementation again (a common occurrence with my recent PRs here)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Although this still doesn't allow us to access data stored within the HostStatus objects, which would be needed for displaying the /usr overlay status (#1258).
Unless you're thinking that can also be moved to be stored under BootEntry? Or am I completely overthinking the implementation again (a common occurrence with my recent PRs here)?

As is today, a usroverlay state is transient by default. It'd only be hotfix ones that we need to maintain persistently, but I've been trying to really discourage use of the hotfix path.

But anyways yes, we could pass down the metadata ultimately from ostree_deployment_get_unlocked() here.

Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,10 @@ fn write_row_name(mut out: impl Write, s: &str, prefix_len: usize) -> Result<()>
}

/// Write the data for a container image based status.
fn human_render_imagestatus(
fn human_render_slot(
mut out: impl Write,
slot: Slot,
entry: &crate::spec::BootEntry,
image: &crate::spec::ImageStatus,
) -> Result<()> {
let transport = &image.image.transport;
Expand Down Expand Up @@ -407,10 +408,18 @@ fn human_render_imagestatus(
writeln!(out, "{timestamp}")?;
}

tracing::debug!("pinned={}", entry.pinned);

Ok(())
}

fn human_render_ostree(mut out: impl Write, slot: Slot, ostree_commit: &str) -> Result<()> {
/// Output a rendering of a non-container boot entry.
fn human_render_slot_ostree(
mut out: impl Write,
slot: Slot,
entry: &crate::spec::BootEntry,
ostree_commit: &str,
) -> Result<()> {
// TODO consider rendering more ostree stuff here like rpm-ostree status does
let prefix = match slot {
Slot::Staged => " Staged ostree".into(),
Expand All @@ -421,6 +430,7 @@ fn human_render_ostree(mut out: impl Write, slot: Slot, ostree_commit: &str) ->
writeln!(out, "{prefix}")?;
write_row_name(&mut out, "Commit", prefix_len)?;
writeln!(out, "{ostree_commit}")?;
tracing::debug!("pinned={}", entry.pinned);
Ok(())
}

Expand All @@ -438,9 +448,9 @@ fn human_readable_output_booted(mut out: impl Write, host: &Host) -> Result<()>
writeln!(out)?;
}
if let Some(image) = &host_status.image {
human_render_imagestatus(&mut out, slot_name, image)?;
human_render_slot(&mut out, slot_name, host_status, image)?;
} else if let Some(ostree) = host_status.ostree.as_ref() {
human_render_ostree(&mut out, slot_name, &ostree.checksum)?;
human_render_slot_ostree(&mut out, slot_name, host_status, &ostree.checksum)?;
} else {
writeln!(out, "Current {slot_name} state is unknown")?;
}
Expand Down