Skip to content

Commit 782ceb6

Browse files
committed
composefs: Switch to composefs_oci::pull_image() API
Update to the latest API here, just on general principle since it gives us logging info which we use. Assisted-by: OpenCode (Claude Opus 4) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 5c92af0 commit 782ceb6

File tree

3 files changed

+55
-24
lines changed

3 files changed

+55
-24
lines changed

crates/lib/src/bootc_composefs/repo.rs

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ use cfsctl::composefs_oci;
99
use composefs::fsverity::{FsVerityHashValue, Sha512HashValue};
1010
use composefs_boot::{BootOps, bootloader::BootEntry as ComposefsBootEntry};
1111
use composefs_oci::{
12-
PullResult, image::create_filesystem as create_composefs_filesystem, pull as composefs_oci_pull,
12+
image::create_filesystem as create_composefs_filesystem,
13+
pull_image as composefs_oci_pull_image, skopeo::PullResult,
1314
};
1415

1516
use ostree_ext::container::ImageReference as OstreeExtImgRef;
@@ -56,13 +57,25 @@ pub(crate) async fn initialize_composefs_repository(
5657
} = &state.source.imageref;
5758

5859
// transport's display is already of type "<transport_type>:"
59-
composefs_oci_pull(
60+
let (pull_result, _stats) = composefs_oci_pull_image(
6061
&Arc::new(repo),
6162
&format!("{transport}{image_name}"),
6263
None,
6364
None,
6465
)
65-
.await
66+
.await?;
67+
68+
tracing::info!(
69+
message_id = COMPOSEFS_REPO_INIT_JOURNAL_ID,
70+
bootc.operation = "repository_init",
71+
bootc.manifest_digest = pull_result.manifest_digest,
72+
bootc.manifest_verity = pull_result.manifest_verity.to_hex(),
73+
bootc.config_digest = pull_result.config_digest,
74+
bootc.config_verity = pull_result.config_verity.to_hex(),
75+
"Pulled image into composefs repository",
76+
);
77+
78+
Ok(pull_result)
6679
}
6780

6881
/// skopeo (in composefs-rs) doesn't understand "registry:"
@@ -85,19 +98,26 @@ pub(crate) fn get_imgref(transport: &str, image: &str) -> String {
8598
}
8699
}
87100

101+
/// Result of pulling a composefs repository, including the OCI manifest digest
102+
/// needed to reconstruct image metadata from the local composefs repo.
103+
#[allow(dead_code)]
104+
pub(crate) struct PullRepoResult {
105+
pub(crate) repo: crate::store::ComposefsRepository,
106+
pub(crate) entries: Vec<ComposefsBootEntry<Sha512HashValue>>,
107+
pub(crate) id: Sha512HashValue,
108+
pub(crate) fs: crate::store::ComposefsFilesystem,
109+
/// The OCI manifest content digest (e.g. "sha256:abc...")
110+
pub(crate) manifest_digest: String,
111+
}
112+
88113
/// Pulls the `image` from `transport` into a composefs repository at /sysroot
89114
/// Checks for boot entries in the image and returns them
90115
#[context("Pulling composefs repository")]
91116
pub(crate) async fn pull_composefs_repo(
92117
transport: &String,
93118
image: &String,
94119
allow_missing_fsverity: bool,
95-
) -> Result<(
96-
crate::store::ComposefsRepository,
97-
Vec<ComposefsBootEntry<Sha512HashValue>>,
98-
Sha512HashValue,
99-
crate::store::ComposefsFilesystem,
100-
)> {
120+
) -> Result<PullRepoResult> {
101121
const COMPOSEFS_PULL_JOURNAL_ID: &str = "4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8";
102122

103123
tracing::info!(
@@ -120,15 +140,19 @@ pub(crate) async fn pull_composefs_repo(
120140

121141
tracing::debug!("Image to pull {final_imgref}");
122142

123-
let pull_result = composefs_oci_pull(&Arc::new(repo), &final_imgref, None, None)
124-
.await
125-
.context("Pulling composefs repo")?;
143+
let (pull_result, _stats) =
144+
composefs_oci_pull_image(&Arc::new(repo), &final_imgref, None, None)
145+
.await
146+
.context("Pulling composefs repo")?;
126147

127148
tracing::info!(
128149
message_id = COMPOSEFS_PULL_JOURNAL_ID,
129-
id = pull_result.config_digest,
130-
verity = pull_result.config_verity.to_hex(),
131-
"Pulled image into repository"
150+
bootc.operation = "pull",
151+
bootc.manifest_digest = pull_result.manifest_digest,
152+
bootc.manifest_verity = pull_result.manifest_verity.to_hex(),
153+
bootc.config_digest = pull_result.config_digest,
154+
bootc.config_verity = pull_result.config_verity.to_hex(),
155+
"Pulled image into composefs repository",
132156
);
133157

134158
let mut repo = open_composefs_repo(&rootfs_dir)?;
@@ -141,7 +165,13 @@ pub(crate) async fn pull_composefs_repo(
141165
let entries = fs.transform_for_boot(&repo)?;
142166
let id = fs.commit_image(&repo, None)?;
143167

144-
Ok((repo, entries, id, fs))
168+
Ok(PullRepoResult {
169+
repo,
170+
entries,
171+
id,
172+
fs,
173+
manifest_digest: pull_result.manifest_digest,
174+
})
145175
}
146176

147177
#[cfg(test)]

crates/lib/src/bootc_composefs/update.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,13 @@ pub(crate) async fn do_upgrade(
255255
) -> Result<()> {
256256
start_finalize_stated_svc()?;
257257

258-
let (repo, entries, id, fs) = pull_composefs_repo(
258+
let crate::bootc_composefs::repo::PullRepoResult {
259+
repo,
260+
entries,
261+
id,
262+
fs,
263+
manifest_digest: _,
264+
} = pull_composefs_repo(
259265
&imgref.transport,
260266
&imgref.image,
261267
booted_cfs.cmdline.allow_missing_fsverity,

crates/lib/src/install.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,7 @@ use crate::task::Task;
201201
use crate::utils::sigpolicy_from_opt;
202202
use bootc_kernel_cmdline::{INITRD_ARG_PREFIX, ROOTFLAGS, bytes, utf8};
203203
use bootc_mount::Filesystem;
204-
use cfsctl::composefs;
205-
use composefs::fsverity::FsVerityHashValue;
204+
206205

207206
/// The toplevel boot directory
208207
pub(crate) const BOOT: &str = "boot";
@@ -1959,11 +1958,7 @@ async fn install_to_filesystem_impl(
19591958
state.composefs_options.allow_missing_verity,
19601959
)
19611960
.await?;
1962-
tracing::info!(
1963-
"id: {}, verity: {}",
1964-
pull_result.config_digest,
1965-
pull_result.config_verity.to_hex()
1966-
);
1961+
19671962

19681963
setup_composefs_boot(
19691964
rootfs,

0 commit comments

Comments
 (0)