Skip to content

Commit

Permalink
Merge pull request #231 from cgwalters/bump-ext
Browse files Browse the repository at this point in the history
deploy: Use new ostree-ext pruning API
  • Loading branch information
vrothberg authored Dec 18, 2023
2 parents 5463470 + b5b8cab commit 2486672
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 2486672

Please sign in to comment.