Skip to content

Commit 3c31d9f

Browse files
authored
Merge pull request #726 from cgwalters/deploy-pull-imgref
install: Correctly set target imgref at pull time
2 parents fe5225b + c12bb3c commit 3c31d9f

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

lib/src/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ async fn upgrade(opts: UpgradeOpts) -> Result<()> {
549549
}
550550
}
551551
} else {
552-
let fetched = crate::deploy::pull(repo, imgref, opts.quiet).await?;
552+
let fetched = crate::deploy::pull(repo, imgref, None, opts.quiet).await?;
553553
let staged_digest = staged_image.as_ref().map(|s| s.image_digest.as_str());
554554
let fetched_digest = fetched.manifest_digest.as_str();
555555
tracing::debug!("staged: {staged_digest:?}");
@@ -642,7 +642,7 @@ async fn switch(opts: SwitchOpts) -> Result<()> {
642642
}
643643
let new_spec = RequiredHostSpec::from_spec(&new_spec)?;
644644

645-
let fetched = crate::deploy::pull(repo, &target, opts.quiet).await?;
645+
let fetched = crate::deploy::pull(repo, &target, None, opts.quiet).await?;
646646

647647
if !opts.retain {
648648
// 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<()> {
700700
return crate::deploy::rollback(sysroot).await;
701701
}
702702

703-
let fetched = crate::deploy::pull(repo, new_spec.image, opts.quiet).await?;
703+
let fetched = crate::deploy::pull(repo, new_spec.image, None, opts.quiet).await?;
704704

705705
// TODO gc old layers here
706706

lib/src/deploy.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,14 @@ async fn handle_layer_progress_print(
223223
pub(crate) async fn pull(
224224
repo: &ostree::Repo,
225225
imgref: &ImageReference,
226+
target_imgref: Option<&OstreeImageReference>,
226227
quiet: bool,
227228
) -> Result<Box<ImageState>> {
228229
let ostree_imgref = &OstreeImageReference::from(imgref.clone());
229230
let mut imp = new_importer(repo, ostree_imgref).await?;
231+
if let Some(target) = target_imgref {
232+
imp.set_target(target);
233+
}
230234
let prep = match imp.prepare().await? {
231235
PrepareResult::AlreadyPresent(c) => {
232236
println!("No changes in {imgref:#} => {}", c.manifest_digest);
@@ -254,8 +258,10 @@ pub(crate) async fn pull(
254258
let _ = printer.await;
255259
}
256260
let import = import?;
261+
let wrote_imgref = target_imgref.as_ref().unwrap_or(&ostree_imgref);
257262
if let Some(msg) =
258-
ostree_container::store::image_filtered_content_warning(repo, &ostree_imgref.imgref)?
263+
ostree_container::store::image_filtered_content_warning(repo, &wrote_imgref.imgref)
264+
.context("Image content warning")?
259265
{
260266
crate::journal::journal_print(libsystemd::logging::Priority::Notice, &msg);
261267
}

lib/src/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ async fn install_container(
668668
let spec_imgref = ImageReference::from(src_imageref.clone());
669669
let repo = &sysroot.repo();
670670
repo.set_disable_fsync(true);
671-
crate::deploy::pull(repo, &spec_imgref, false).await?;
671+
crate::deploy::pull(repo, &spec_imgref, Some(&state.target_imgref), false).await?;
672672
repo.set_disable_fsync(false);
673673
}
674674

0 commit comments

Comments
 (0)