Skip to content
Open
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
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions contrib/packaging/fedora-extra-optional.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Packages that are only needed by some tests, and that we do not require to
# be available everywhere we build. Anything listed here must be optional:
# install-buildroot carries on without it, and the tests that use it skip
# themselves when it is absent.
#
# Generates the deltas the `--from-delta` tests apply.
oci-delta
5 changes: 5 additions & 0 deletions contrib/packaging/install-buildroot
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ dnf -y distro-sync ostree{,-libs} systemd
dnf -y builddep bootc.spec
# And extra packages
grep -Ev -e '^#' fedora-extra.txt | xargs dnf -y install
# Packages that only enable extra tests, and are not in every distribution we
# build on. The tests that want these skip themselves when they are missing.
for pkg in $(grep -Ev -e '^#' fedora-extra-optional.txt); do
dnf -y install "$pkg" || echo "warning: optional package $pkg is unavailable"
done
3 changes: 3 additions & 0 deletions crates/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ rust-version = "1.85.0"
include = ["/src", "/build.rs", "LICENSE-APACHE", "LICENSE-MIT"]

[dependencies]
oci-delta = { git = "https://github.com/containers/oci-delta", tag = "rust-v0.1.0" }
# Internal crates
bootc-blockdev = { package = "bootc-internal-blockdev", path = "../blockdev", version = "1.16.12" }
linux-kernel-cmdline = { workspace = true }
Expand Down Expand Up @@ -78,6 +79,8 @@ uuid = { version = "1.8.0", features = ["v4"] }
uapi-version = "0.4.0"

[dev-dependencies]
# For the ostree/container test fixtures
ostree-ext = { path = "../ostree-ext", features = ["bootc", "internal-testing-api"] }
similar-asserts = { workspace = true }
static_assertions = { workspace = true }

Expand Down
20 changes: 19 additions & 1 deletion crates/lib/src/bootc_composefs/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,18 +316,35 @@ async fn pull_composefs_unified(
/// When `use_unified` is false (the default), the image is pulled directly
/// into the composefs repo via skopeo.
///
/// With a `delta`, the content is read from the delta file instead and no
/// network access happens at all; `spec_imgref` then only names what the
/// resulting deployment tracks. composefs-ctl recognises the delta artifact
/// from the layout's manifest and reconstructs the changed layers against the
/// source image in the repository, failing if that image is absent.
///
/// Checks for boot entries in the image and returns them.
#[context("Pulling composefs repository")]
pub(crate) async fn pull_composefs_repo(
spec_imgref: &crate::spec::ImageReference,
delta: Option<&crate::delta::Delta>,
allow_missing_fsverity: bool,
use_unified: bool,
quiet: bool,
prog: ProgressWriter,
) -> Result<PullRepoResult> {
const COMPOSEFS_PULL_JOURNAL_ID: &str = "4c3b2a1f0e9d8c7b6a5f4e3d2c1b0a9f8";

let imgref = spec_imgref.to_image_proxy_ref()?;
let imgref = match delta {
Some(delta) => {
delta.validate_image_reference(spec_imgref)?;
crate::delta::reject_unified_storage(delta, use_unified)?;
if !quiet {
println!("Applying delta {}", delta.describe());
}
delta.pull_ref()?
}
None => spec_imgref.to_image_proxy_ref()?,
};

tracing::info!(
message_id = COMPOSEFS_PULL_JOURNAL_ID,
Expand All @@ -336,6 +353,7 @@ pub(crate) async fn pull_composefs_repo(
bootc.transport = %imgref.transport,
bootc.allow_missing_fsverity = allow_missing_fsverity,
bootc.unified_storage = use_unified,
bootc.delta = delta.map(|d| d.path.as_str()),
"Pulling composefs image {imgref}",
);

Expand Down
9 changes: 6 additions & 3 deletions crates/lib/src/bootc_composefs/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,13 @@ pub(crate) fn list_bootloader_entries(storage: &Storage) -> Result<Vec<Bootloade
}

/// imgref = transport:image_name
///
/// Returns the image manifest and config, along with the digest of the
/// manifest as the registry reported it.
#[context("Getting container info")]
pub(crate) async fn get_container_manifest_and_config(
imgref: &ImageReference,
) -> Result<ImgConfigManifest> {
) -> Result<(ImgConfigManifest, String)> {
let mut config = crate::deploy::new_proxy_config();

ostree_ext::container::merge_default_container_proxy_opts(&mut config)?;
Expand All @@ -427,7 +430,7 @@ pub(crate) async fn get_container_manifest_and_config(
.await
.with_context(|| format!("Opening image {imgref}"))?;

let (_, manifest) = proxy.fetch_manifest(&img).await?;
let (manifest_digest, manifest) = proxy.fetch_manifest(&img).await?;
let (mut reader, driver) = proxy.get_descriptor(&img, manifest.config()).await?;

let mut buf = Vec::with_capacity(manifest.config().size() as usize);
Expand All @@ -437,7 +440,7 @@ pub(crate) async fn get_container_manifest_and_config(

let config: oci_spec::image::ImageConfiguration = serde_json::from_slice(&buf)?;

Ok(ImgConfigManifest { manifest, config })
Ok((ImgConfigManifest { manifest, config }, manifest_digest))
}

/// Directory where BLS-compatible bootloaders expect Type 1 boot entries.
Expand Down
32 changes: 27 additions & 5 deletions crates/lib/src/bootc_composefs/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use crate::{
status::get_composefs_status,
update::{
DoUpgradeOpts, UpdateAction, apply_upgrade_from_downloaded, do_upgrade,
is_image_pulled, validate_update,
ensure_delta_source_present, is_image_pulled, lookup_config_splitstream,
validate_update,
},
},
cli::{SwitchOpts, imgref_for_switch},
Expand All @@ -25,6 +26,8 @@ pub(crate) async fn switch_composefs(
.await
.context("Getting composefs deployment status")?;

let delta = crate::delta::open_opt(opts.from_delta.as_deref()).await?;

let prog: ProgressWriter = opts.progress.clone().try_into()?;

let mut do_upgrade_opts = DoUpgradeOpts {
Expand All @@ -34,13 +37,17 @@ pub(crate) async fn switch_composefs(
use_unified: false,
quiet: opts.quiet,
prog,
delta: delta.as_ref(),
};

if opts.download_opts.from_downloaded {
return apply_upgrade_from_downloaded(storage, booted_cfs, &host, &do_upgrade_opts).await;
}

let target = imgref_for_switch(&opts)?;
if let Some(delta) = delta.as_ref() {
delta.validate_image_reference(&target)?;
}

let new_spec = {
let mut new_spec = host.spec.clone();
Expand Down Expand Up @@ -92,14 +99,29 @@ pub(crate) async fn switch_composefs(
booted_unified || target_unified
};

let (image, img_config) = is_image_pulled(repo, &target_imgref).await?;
// With a delta the target is whatever the delta says it is, and we can look
// it up locally; without one we have to ask the registry.
let (image, manifest) = match &delta {
Some(delta) => {
crate::delta::reject_unified_storage(delta, do_upgrade_opts.use_unified)?;
ensure_delta_source_present(repo, delta)?;
(
lookup_config_splitstream(repo, delta.target_manifest().config().digest())?,
delta.target_manifest().clone(),
)
}
None => {
let (image, img_config, _) = is_image_pulled(repo, &target_imgref).await?;
(image, img_config.manifest)
}
};

if let Some(cfg_verity) = image {
let action = validate_update(
storage,
booted_cfs,
&host,
img_config.manifest.config().digest().as_ref(),
manifest.config().digest().as_ref(),
&cfg_verity,
true,
)?;
Expand All @@ -117,7 +139,7 @@ pub(crate) async fn switch_composefs(
&host,
&target_imgref,
&do_upgrade_opts,
&img_config.manifest,
&manifest,
)
.await;
}
Expand All @@ -130,7 +152,7 @@ pub(crate) async fn switch_composefs(
&host,
&target_imgref,
&do_upgrade_opts,
&img_config.manifest,
&manifest,
)
.await?;

Expand Down
Loading
Loading