Skip to content

Commit

Permalink
deploy: Use new ostree-ext pruning API
Browse files Browse the repository at this point in the history
This will ensure we're really pruning everything.
xref coreos/rpm-ostree#4720

Signed-off-by: Colin Walters <walters@verbum.org>
  • Loading branch information
cgwalters committed Dec 15, 2023
1 parent 5463470 commit b5b8cab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ anstream = "0.6.4"
anstyle = "1.0.4"
anyhow = "1.0"
camino = { version = "1.0.4", features = ["serde1"] }
ostree-ext = { version = "0.12", git = "https://github.com/ostreedev/ostree-rs-ext/"}
ostree-ext = { version = "0.12.8" }
chrono = { version = "0.4.23", features = ["serde"] }
clap = { version= "4.2", features = ["derive"] }
clap_mangen = { version = "0.2", optional = true }
Expand Down
14 changes: 13 additions & 1 deletion lib/src/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ pub(crate) async fn pull(
}

pub(crate) async fn cleanup(sysroot: &SysrootLock) -> Result<()> {
// We create clones (just atomic reference bumps) here to move to the thread.
let repo = sysroot.repo();
let sysroot = sysroot.sysroot.clone();
ostree_ext::tokio_util::spawn_blocking_cancellable_flatten(move |cancellable| {
let locked_sysroot = &SysrootLock::from_assumed_locked(&sysroot);
let cancellable = Some(cancellable);
let repo = &repo;
let txn = repo.auto_transaction(cancellable)?;
Expand Down Expand Up @@ -152,6 +154,17 @@ pub(crate) async fn cleanup(sysroot: &SysrootLock) -> Result<()> {
}
}

let pruned = ostree_container::deploy::prune(locked_sysroot).context("Pruning images")?;
if !pruned.is_empty() {
let size = glib::format_size(pruned.objsize);
println!(
"Pruned images: {} (layers: {}, objsize: {})",
pruned.n_images, pruned.n_layers, size
);
} else {
tracing::debug!("Nothing to prune");
}

Ok(())
})
.await
Expand Down Expand Up @@ -219,7 +232,6 @@ pub(crate) async fn stage(
println!(" Version: {version}");
}
println!(" Digest: {}", image.manifest_digest);
ostree_container::deploy::remove_undeployed_images(sysroot).context("Pruning images")?;

Ok(())
}

0 comments on commit b5b8cab

Please sign in to comment.