Skip to content

Commit ec49f47

Browse files
authored
ensure blob directory exists in archives (#77)
The helios-omicron-brand code that unpacks zone images requires all file entries in an archive to be preceded by entries that create those files' directories. Ensure the packaging code adds the requisite entries for downloaded blobs (as it already does for Rust programs). Propolis will need a patch release containing this fix to produce functioning Omicron zone images, so I've bumped the package version to 0.12.2 in this commit; let me know if I should do that in a separate PR. Tested by building a Propolis package using this commit and verifying that (a) tar -tzf prints the appropriate output structure, and (b) hotpatching an Omicron dev cluster with this zone image allows instances to start (images created without the fix produce a file-not-found error when sled-agent tries to start them).
1 parent eaca141 commit ec49f47

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "omicron-zone-package"
3-
version = "0.12.1"
3+
version = "0.12.2"
44
authors = ["Sean Klein <[email protected]>"]
55
edition = "2021"
66
rust-version = "1.81.0"

src/package.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,15 +603,30 @@ impl Package {
603603
fn get_blobs_inputs(&self, download_directory: &Utf8Path, zoned: bool) -> Result<BuildInputs> {
604604
let mut inputs = BuildInputs::new();
605605

606+
// If there are no blobs in the source description, there's no work to
607+
// do. It's important to short-circuit here to avoid adding an empty
608+
// blob directory entry to zone archives that won't actually contain
609+
// any blobs.
610+
if self.source.blobs().is_none() && self.source.buildomat_blobs().is_none() {
611+
return Ok(inputs);
612+
}
613+
606614
let destination_path = if zoned {
607-
zone_archive_path(
608-
&Utf8Path::new("/opt/oxide")
609-
.join(self.service_name.as_str())
610-
.join(BLOB),
611-
)?
615+
let dst = Utf8Path::new("/opt/oxide")
616+
.join(self.service_name.as_str())
617+
.join(BLOB);
618+
619+
inputs.0.extend(
620+
zone_get_all_parent_inputs(&dst)?
621+
.into_iter()
622+
.map(BuildInput::AddDirectory),
623+
);
624+
625+
zone_archive_path(&dst)?
612626
} else {
613627
Utf8PathBuf::from(BLOB)
614628
};
629+
615630
if let Some(s3_blobs) = self.source.blobs() {
616631
inputs.0.extend(s3_blobs.iter().map(|blob| {
617632
let from = download_directory

0 commit comments

Comments
 (0)