Skip to content
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

status: Add some error context #187

Merged
merged 1 commit into from
Nov 7, 2023
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
12 changes: 9 additions & 3 deletions lib/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::collections::VecDeque;
use crate::spec::{BootEntry, Host, HostSpec, HostStatus, ImageStatus};
use crate::spec::{ImageReference, ImageSignature};
use anyhow::{Context, Result};
use fn_error_context::context;
use ostree::glib;
use ostree_container::OstreeImageReference;
use ostree_ext::container as ostree_container;
Expand Down Expand Up @@ -104,6 +105,7 @@ pub(crate) fn labels_of_config(
config.config().as_ref().and_then(|c| c.labels().as_ref())
}

#[context("Reading deployment metadata")]
fn boot_entry_from_deployment(
sysroot: &SysrootLock,
deployment: &ostree::Deployment,
Expand Down Expand Up @@ -183,6 +185,7 @@ pub(crate) fn get_status_require_booted(

/// Gather the ostree deployment objects, but also extract metadata from them into
/// a more native Rust structure.
#[context("Computing status")]
pub(crate) fn get_status(
sysroot: &SysrootLock,
booted_deployment: Option<&ostree::Deployment>,
Expand Down Expand Up @@ -217,16 +220,19 @@ pub(crate) fn get_status(
.staged
.as_ref()
.map(|d| boot_entry_from_deployment(sysroot, d))
.transpose()?;
.transpose()
.context("Staged deployment")?;
let booted = booted_deployment
.as_ref()
.map(|d| boot_entry_from_deployment(sysroot, d))
.transpose()?;
.transpose()
.context("Booted deployment")?;
let rollback = deployments
.rollback
.as_ref()
.map(|d| boot_entry_from_deployment(sysroot, d))
.transpose()?;
.transpose()
.context("Rollback deployment")?;
let spec = staged
.as_ref()
.or(booted.as_ref())
Expand Down
Loading