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

deploy: Use new ostree-ext pruning API #231

Merged
merged 1 commit into from
Dec 18, 2023
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
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(())
}