MCPcopy Create free account
hub / github.com/bootc-dev/bootc / prune_container_store

Function prune_container_store

crates/lib/src/deploy.rs:398–426  ·  view source on GitHub ↗

Gather all bound images in all deployments, then prune the image store, using the gathered images as the roots (that will not be GC'd).

(sysroot: &Storage)

Source from the content-addressed store, hash-verified

396/// Gather all bound images in all deployments, then prune the image store,
397/// using the gathered images as the roots (that will not be GC'd).
398pub(crate) async fn prune_container_store(sysroot: &Storage) -> Result<()> {
399 let ostree = sysroot.get_ostree()?;
400 let deployments = ostree.deployments();
401 let mut all_bound_images = Vec::new();
402 for deployment in deployments {
403 let bound = crate::boundimage::query_bound_images_for_deployment(ostree, &deployment)?;
404 all_bound_images.extend(bound.into_iter());
405 // Also include the host image itself
406 // Note: Use just the image name (not the full transport:image format) because
407 // podman's image names don't include the transport prefix.
408 if let Some(host_image) = crate::status::boot_entry_from_deployment(ostree, &deployment)?
409 .image
410 .map(|i| i.image)
411 {
412 all_bound_images.push(crate::boundimage::BoundImage {
413 image: host_image.image.clone(),
414 auth_file: None,
415 });
416 }
417 }
418 // Convert to a hashset of just the image names
419 let image_names = HashSet::from_iter(all_bound_images.iter().map(|img| img.image.as_str()));
420 let pruned = sysroot
421 .get_ensure_imgstore()?
422 .prune_except_roots(&image_names)
423 .await?;
424 tracing::debug!("Pruned images: {}", pruned.len());
425 Ok(())
426}
427
428/// Core disk space check: verify that `bytes_to_fetch` fits within available space,
429/// leaving at least `min_free` bytes reserved.

Callers 1

cleanupFunction · 0.85

Calls 9

get_ostreeMethod · 0.80
deploymentsMethod · 0.80
prune_except_rootsMethod · 0.80
get_ensure_imgstoreMethod · 0.80
extendMethod · 0.45
into_iterMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected