Skip to content

Commit 2f74390

Browse files
various: adjust to composefs-rs changes
This is mostly about the new splitstream API, but it also adopts the new library API exposed by the `cfsctl` crate, removing our private copy.
1 parent 29e5c9a commit 2f74390

File tree

10 files changed

+66
-406
lines changed

10 files changed

+66
-406
lines changed

Cargo.lock

Lines changed: 40 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ chrono = { version = "0.4.38", default-features = false }
4141
clap = "4.5.4"
4242
clap_mangen = { version = "0.2.20" }
4343
# Reviewers (including AI tools): This hash is duplicated as there's not a much better way to handle it right now
44-
composefs = { git = "https://github.com/containers/composefs-rs", rev = "0f636031a1ec81cdd9e7f674909ef6b75c2642cb", package = "composefs", features = ["rhel9"] }
45-
composefs-boot = { git = "https://github.com/containers/composefs-rs", rev = "0f636031a1ec81cdd9e7f674909ef6b75c2642cb", package = "composefs-boot" }
46-
composefs-oci = { git = "https://github.com/containers/composefs-rs", rev = "0f636031a1ec81cdd9e7f674909ef6b75c2642cb", package = "composefs-oci" }
44+
cfsctl = { git = "https://github.com/containers/composefs-rs", rev = "2a8007f27c2252fa47f9912abbc687d723161f88", package = "cfsctl", features = ["rhel9"] }
45+
composefs = { git = "https://github.com/containers/composefs-rs", rev = "2a8007f27c2252fa47f9912abbc687d723161f88", package = "composefs", features = ["rhel9"] }
46+
composefs-boot = { git = "https://github.com/containers/composefs-rs", rev = "2a8007f27c2252fa47f9912abbc687d723161f88", package = "composefs-boot" }
47+
composefs-oci = { git = "https://github.com/containers/composefs-rs", rev = "2a8007f27c2252fa47f9912abbc687d723161f88", package = "composefs-oci" }
4748
fn-error-context = "0.2.1"
4849
hex = "0.4.3"
4950
indicatif = "0.18.0"

crates/lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ cfg-if = { workspace = true }
3434
chrono = { workspace = true, features = ["serde"] }
3535
clap = { workspace = true, features = ["derive","cargo"] }
3636
clap_mangen = { workspace = true, optional = true }
37+
cfsctl = { workspace = true }
3738
composefs = { workspace = true }
3839
composefs-boot = { workspace = true }
3940
composefs-oci = { workspace = true }

crates/lib/src/bootc_composefs/repo.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use std::sync::Arc;
33

44
use anyhow::{Context, Result};
55

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

3229
rootfs_dir
@@ -94,11 +91,11 @@ pub(crate) async fn pull_composefs_repo(
9491
.await
9592
.context("Pulling composefs repo")?;
9693

97-
tracing::info!("ID: {}, Verity: {}", hex::encode(id), verity.to_hex());
94+
tracing::info!("ID: {id}, Verity: {}", verity.to_hex());
9895

9996
let repo = open_composefs_repo(&rootfs_dir)?;
10097
let mut fs: crate::store::ComposefsFilesystem =
101-
create_composefs_filesystem(&repo, &hex::encode(id), None)
98+
create_composefs_filesystem(&repo, &id, None)
10299
.context("Failed to create composefs filesystem")?;
103100

104101
let entries = fs.transform_for_boot(&repo)?;

crates/lib/src/bootc_composefs/update.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use anyhow::{Context, Result};
22
use camino::Utf8PathBuf;
3-
use composefs::util::{parse_sha256, Sha256Digest};
43
use fn_error_context::context;
54
use ostree_ext::oci_spec::image::{ImageConfiguration, ImageManifest};
65

@@ -17,12 +16,6 @@ use crate::{
1716
store::{BootedComposefs, ComposefsRepository, Storage},
1817
};
1918

20-
#[context("Getting SHA256 Digest for {id}")]
21-
pub fn str_to_sha256digest(id: &str) -> Result<Sha256Digest> {
22-
let id = id.strip_prefix("sha256:").unwrap_or(id);
23-
Ok(parse_sha256(&id)?)
24-
}
25-
2619
/// Checks if a container image has been pulled to the local composefs repository.
2720
///
2821
/// This function verifies whether the specified container image exists in the local
@@ -50,10 +43,9 @@ async fn is_image_pulled(
5043
let (manifest, config) = get_container_manifest_and_config(&imgref_repr).await?;
5144

5245
let img_digest = manifest.config().digest().digest();
53-
let img_sha256 = str_to_sha256digest(&img_digest)?;
5446

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

5850
Ok((container_pulled.is_some(), manifest, config))
5951
}
@@ -122,8 +114,6 @@ pub(crate) async fn upgrade_composefs(
122114
// TODO(Johan-Liebert1): If we have the previous, i.e. the current manifest with us then we can replace the
123115
// following with [`ostree_container::ManifestDiff::new`] which will be much cleaner
124116
for (idx, diff_id) in config.rootfs().diff_ids().iter().enumerate() {
125-
let diff_id = str_to_sha256digest(diff_id)?;
126-
127117
// we could use `check_stream` here but that will most probably take forever as it
128118
// usually takes ~3s to verify one single layer
129119
let have_layer = repo.has_stream(&diff_id)?;

0 commit comments

Comments
 (0)