From f2a517a2fc173b0e3166c400588f646bf38e0e94 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Jun 2024 16:20:51 -0400 Subject: [PATCH] install: Use separate pull stage for progress output The goal here is to get interactive progress on pulling, as that can be slow and also I'd like to get more information there. Signed-off-by: Colin Walters --- lib/src/cli.rs | 9 +++++---- lib/src/deploy.rs | 3 +-- lib/src/install.rs | 7 +++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/src/cli.rs b/lib/src/cli.rs index ccfb87a99..366384930 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -534,7 +534,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> { } } } else { - let fetched = crate::deploy::pull(sysroot, imgref, opts.quiet).await?; + let fetched = crate::deploy::pull(repo, imgref, opts.quiet).await?; let kargs = crate::kargs::get_kargs(repo, &booted_deployment, fetched.as_ref())?; let staged_digest = staged_image.as_ref().map(|s| s.image_digest.as_str()); let fetched_digest = fetched.manifest_digest.as_str(); @@ -631,7 +631,7 @@ async fn switch(opts: SwitchOpts) -> Result<()> { } let new_spec = RequiredHostSpec::from_spec(&new_spec)?; - let fetched = crate::deploy::pull(sysroot, &target, opts.quiet).await?; + let fetched = crate::deploy::pull(repo, &target, opts.quiet).await?; let kargs = crate::kargs::get_kargs(repo, &booted_deployment, fetched.as_ref())?; if !opts.retain { @@ -665,6 +665,8 @@ async fn rollback(_opts: RollbackOpts) -> Result<()> { #[context("Editing spec")] async fn edit(opts: EditOpts) -> Result<()> { let sysroot = &get_locked_sysroot().await?; + let repo = &sysroot.repo(); + let (booted_deployment, _deployments, host) = crate::status::get_status_require_booted(sysroot)?; let new_host: Host = if let Some(filename) = opts.filename { @@ -691,8 +693,7 @@ async fn edit(opts: EditOpts) -> Result<()> { return crate::deploy::rollback(sysroot).await; } - let fetched = crate::deploy::pull(sysroot, new_spec.image, opts.quiet).await?; - let repo = &sysroot.repo(); + let fetched = crate::deploy::pull(repo, new_spec.image, opts.quiet).await?; let kargs = crate::kargs::get_kargs(repo, &booted_deployment, fetched.as_ref())?; // TODO gc old layers here diff --git a/lib/src/deploy.rs b/lib/src/deploy.rs index f0508f4fe..e6d6a4629 100644 --- a/lib/src/deploy.rs +++ b/lib/src/deploy.rs @@ -164,11 +164,10 @@ async fn handle_layer_progress_print( /// Wrapper for pulling a container image, wiring up status output. #[context("Pulling")] pub(crate) async fn pull( - sysroot: &SysrootLock, + repo: &ostree::Repo, imgref: &ImageReference, quiet: bool, ) -> Result> { - let repo = &sysroot.repo(); let ostree_imgref = &OstreeImageReference::from(imgref.clone()); let mut imp = new_importer(repo, ostree_imgref).await?; let prep = match imp.prepare().await? { diff --git a/lib/src/install.rs b/lib/src/install.rs index 4d995f692..1a1608fdd 100644 --- a/lib/src/install.rs +++ b/lib/src/install.rs @@ -40,6 +40,7 @@ use serde::{Deserialize, Serialize}; use self::baseline::InstallBlockDeviceOpts; use crate::containerenv::ContainerExecutionInfo; use crate::mount::Filesystem; +use crate::spec::ImageReference; use crate::task::Task; use crate::utils::sigpolicy_from_opts; @@ -651,6 +652,12 @@ async fn initialize_ostree_root_from_self( imgref: src_imageref, }; + // Pull the container image into the target root filesystem. + { + let spec_imgref = ImageReference::from(src_imageref.clone()); + crate::deploy::pull(&sysroot.repo(), &spec_imgref, false).await?; + } + // Load the kargs from the /usr/lib/bootc/kargs.d from the running root, // which should be the same as the filesystem we'll deploy. let kargsd = crate::kargs::get_kargs_in_root(container_rootfs, std::env::consts::ARCH)?;