Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install: Correctly set target imgref at pull time #726

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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