From c12bb3cbe6c90afcf8a7b8663425dd271834da08 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 24 Jul 2024 16:37:01 -0400 Subject: [PATCH] install: Correctly set target imgref at pull time We broke `bootc image copy-to-storage` because the change to run a separate pull phase was using the digested (source) pull spec incorrectly. Somehow the deploy phase was picking that up and not also writing the non-digested (target) spec. Signed-off-by: Colin Walters --- lib/src/cli.rs | 6 +++--- lib/src/deploy.rs | 8 +++++++- lib/src/install.rs | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/src/cli.rs b/lib/src/cli.rs index 97fa35d9c..a336246e1 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -549,7 +549,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> { } } } else { - let fetched = crate::deploy::pull(repo, imgref, opts.quiet).await?; + let fetched = crate::deploy::pull(repo, imgref, None, opts.quiet).await?; let staged_digest = staged_image.as_ref().map(|s| s.image_digest.as_str()); let fetched_digest = fetched.manifest_digest.as_str(); tracing::debug!("staged: {staged_digest:?}"); @@ -642,7 +642,7 @@ async fn switch(opts: SwitchOpts) -> Result<()> { } let new_spec = RequiredHostSpec::from_spec(&new_spec)?; - let fetched = crate::deploy::pull(repo, &target, opts.quiet).await?; + let fetched = crate::deploy::pull(repo, &target, None, opts.quiet).await?; if !opts.retain { // By default, we prune the previous ostree ref so it will go away after later upgrades @@ -700,7 +700,7 @@ async fn edit(opts: EditOpts) -> Result<()> { return crate::deploy::rollback(sysroot).await; } - let fetched = crate::deploy::pull(repo, new_spec.image, opts.quiet).await?; + let fetched = crate::deploy::pull(repo, new_spec.image, None, opts.quiet).await?; // TODO gc old layers here diff --git a/lib/src/deploy.rs b/lib/src/deploy.rs index 59325b264..6f9e7d306 100644 --- a/lib/src/deploy.rs +++ b/lib/src/deploy.rs @@ -223,10 +223,14 @@ async fn handle_layer_progress_print( pub(crate) async fn pull( repo: &ostree::Repo, imgref: &ImageReference, + target_imgref: Option<&OstreeImageReference>, quiet: bool, ) -> Result> { let ostree_imgref = &OstreeImageReference::from(imgref.clone()); let mut imp = new_importer(repo, ostree_imgref).await?; + if let Some(target) = target_imgref { + imp.set_target(target); + } let prep = match imp.prepare().await? { PrepareResult::AlreadyPresent(c) => { println!("No changes in {imgref:#} => {}", c.manifest_digest); @@ -254,8 +258,10 @@ pub(crate) async fn pull( let _ = printer.await; } let import = import?; + let wrote_imgref = target_imgref.as_ref().unwrap_or(&ostree_imgref); if let Some(msg) = - ostree_container::store::image_filtered_content_warning(repo, &ostree_imgref.imgref)? + ostree_container::store::image_filtered_content_warning(repo, &wrote_imgref.imgref) + .context("Image content warning")? { crate::journal::journal_print(libsystemd::logging::Priority::Notice, &msg); } diff --git a/lib/src/install.rs b/lib/src/install.rs index 66139ecd3..ae68f352b 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -668,7 +668,7 @@ async fn install_container( let spec_imgref = ImageReference::from(src_imageref.clone()); let repo = &sysroot.repo(); repo.set_disable_fsync(true); - crate::deploy::pull(repo, &spec_imgref, false).await?; + crate::deploy::pull(repo, &spec_imgref, Some(&state.target_imgref), false).await?; repo.set_disable_fsync(false); }