Skip to content
Draft
Show file tree
Hide file tree
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
44 changes: 40 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ chrono = { version = "0.4.38", default-features = false }
clap = "4.5.4"
clap_mangen = { version = "0.2.20" }
# Reviewers (including AI tools): This hash is duplicated as there's not a much better way to handle it right now
composefs = { git = "https://github.com/containers/composefs-rs", rev = "0f636031a1ec81cdd9e7f674909ef6b75c2642cb", package = "composefs", features = ["rhel9"] }
composefs-boot = { git = "https://github.com/containers/composefs-rs", rev = "0f636031a1ec81cdd9e7f674909ef6b75c2642cb", package = "composefs-boot" }
composefs-oci = { git = "https://github.com/containers/composefs-rs", rev = "0f636031a1ec81cdd9e7f674909ef6b75c2642cb", package = "composefs-oci" }
cfsctl = { git = "https://github.com/containers/composefs-rs", rev = "2a8007f27c2252fa47f9912abbc687d723161f88", package = "cfsctl", features = ["rhel9"] }
composefs = { git = "https://github.com/containers/composefs-rs", rev = "2a8007f27c2252fa47f9912abbc687d723161f88", package = "composefs", features = ["rhel9"] }
composefs-boot = { git = "https://github.com/containers/composefs-rs", rev = "2a8007f27c2252fa47f9912abbc687d723161f88", package = "composefs-boot" }
composefs-oci = { git = "https://github.com/containers/composefs-rs", rev = "2a8007f27c2252fa47f9912abbc687d723161f88", package = "composefs-oci" }
fn-error-context = "0.2.1"
hex = "0.4.3"
indicatif = "0.18.0"
Expand Down
1 change: 1 addition & 0 deletions crates/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ cfg-if = { workspace = true }
chrono = { workspace = true, features = ["serde"] }
clap = { workspace = true, features = ["derive","cargo"] }
clap_mangen = { workspace = true, optional = true }
cfsctl = { workspace = true }
composefs = { workspace = true }
composefs-boot = { workspace = true }
composefs-oci = { workspace = true }
Expand Down
11 changes: 4 additions & 7 deletions crates/lib/src/bootc_composefs/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ use std::sync::Arc;

use anyhow::{Context, Result};

use ostree_ext::composefs::{
fsverity::{FsVerityHashValue, Sha512HashValue},
util::Sha256Digest,
};
use ostree_ext::composefs::fsverity::{FsVerityHashValue, Sha512HashValue};
use ostree_ext::composefs_boot::{bootloader::BootEntry as ComposefsBootEntry, BootOps};
use ostree_ext::composefs_oci::{
image::create_filesystem as create_composefs_filesystem, pull as composefs_oci_pull,
Expand All @@ -26,7 +23,7 @@ pub(crate) fn open_composefs_repo(rootfs_dir: &Dir) -> Result<crate::store::Comp
pub(crate) async fn initialize_composefs_repository(
state: &State,
root_setup: &RootSetup,
) -> Result<(Sha256Digest, impl FsVerityHashValue)> {
) -> Result<(String, impl FsVerityHashValue)> {
let rootfs_dir = &root_setup.physical_root;

rootfs_dir
Expand Down Expand Up @@ -94,11 +91,11 @@ pub(crate) async fn pull_composefs_repo(
.await
.context("Pulling composefs repo")?;

tracing::info!("ID: {}, Verity: {}", hex::encode(id), verity.to_hex());
tracing::info!("ID: {id}, Verity: {}", verity.to_hex());

let repo = open_composefs_repo(&rootfs_dir)?;
let mut fs: crate::store::ComposefsFilesystem =
create_composefs_filesystem(&repo, &hex::encode(id), None)
create_composefs_filesystem(&repo, &id, None)
.context("Failed to create composefs filesystem")?;

let entries = fs.transform_for_boot(&repo)?;
Expand Down
14 changes: 2 additions & 12 deletions crates/lib/src/bootc_composefs/update.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use anyhow::{Context, Result};
use camino::Utf8PathBuf;
use composefs::util::{parse_sha256, Sha256Digest};
use fn_error_context::context;
use ostree_ext::oci_spec::image::{ImageConfiguration, ImageManifest};

Expand All @@ -17,12 +16,6 @@ use crate::{
store::{BootedComposefs, ComposefsRepository, Storage},
};

#[context("Getting SHA256 Digest for {id}")]
pub fn str_to_sha256digest(id: &str) -> Result<Sha256Digest> {
let id = id.strip_prefix("sha256:").unwrap_or(id);
Ok(parse_sha256(&id)?)
}

/// Checks if a container image has been pulled to the local composefs repository.
///
/// This function verifies whether the specified container image exists in the local
Expand Down Expand Up @@ -50,10 +43,9 @@ async fn is_image_pulled(
let (manifest, config) = get_container_manifest_and_config(&imgref_repr).await?;

let img_digest = manifest.config().digest().digest();
let img_sha256 = str_to_sha256digest(&img_digest)?;

// check_stream is expensive to run, but probably a good idea
let container_pulled = repo.check_stream(&img_sha256).context("Checking stream")?;
// NB: add deep checking?
let container_pulled = repo.has_stream(&img_digest).context("Checking stream")?;

Ok((container_pulled.is_some(), manifest, config))
}
Expand Down Expand Up @@ -122,8 +114,6 @@ pub(crate) async fn upgrade_composefs(
// TODO(Johan-Liebert1): If we have the previous, i.e. the current manifest with us then we can replace the
// following with [`ostree_container::ManifestDiff::new`] which will be much cleaner
for (idx, diff_id) in config.rootfs().diff_ids().iter().enumerate() {
let diff_id = str_to_sha256digest(diff_id)?;

// we could use `check_stream` here but that will most probably take forever as it
// usually takes ~3s to verify one single layer
let have_layer = repo.has_stream(&diff_id)?;
Expand Down
Loading
Loading