Skip to content

Commit

Permalink
Merge pull request #726 from cgwalters/deploy-pull-imgref
Browse files Browse the repository at this point in the history
install: Correctly set target imgref at pull time
  • Loading branch information
cgwalters authored Jul 24, 2024
2 parents fe5225b + c12bb3c commit 3c31d9f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion lib/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Box<ImageState>> {
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);
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 3c31d9f

Please sign in to comment.