Skip to content
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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "omicron-zone-package"
version = "0.12.1"
version = "0.12.2"
authors = ["Sean Klein <sean@oxidecomputer.com>"]
edition = "2021"
rust-version = "1.81.0"
Expand Down
25 changes: 20 additions & 5 deletions src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,15 +603,30 @@ impl Package {
fn get_blobs_inputs(&self, download_directory: &Utf8Path, zoned: bool) -> Result<BuildInputs> {
let mut inputs = BuildInputs::new();

// If there are no blobs in the source description, there's no work to
// do. It's important to short-circuit here to avoid adding an empty
// blob directory entry to zone archives that won't actually contain
// any blobs.
if self.source.blobs().is_none() && self.source.buildomat_blobs().is_none() {
return Ok(inputs);
}

let destination_path = if zoned {
zone_archive_path(
&Utf8Path::new("/opt/oxide")
.join(self.service_name.as_str())
.join(BLOB),
)?
let dst = Utf8Path::new("/opt/oxide")
.join(self.service_name.as_str())
.join(BLOB);

inputs.0.extend(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe tests are failing because we're adding these directories, even if no blob inputs actually exist

Copy link
Collaborator

@smklein smklein Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following change works for me:

     fn get_blobs_inputs(&self, download_directory: &Utf8Path, zoned: bool) -> Result<BuildInputs> {
         let mut inputs = BuildInputs::new();
 
+        let s3_blobs = self.source.blobs();
+        let buildomat_blobs = self.source.buildomat_blobs();
+        let any_blobs = s3_blobs.is_some() || buildomat_blobs.is_some();
+
         let destination_path = if zoned {
-            zone_archive_path(
-                &Utf8Path::new("/opt/oxide")
-                    .join(self.service_name.as_str())
-                    .join(BLOB),
-            )?
+            let dst = Utf8Path::new("/opt/oxide")
+                .join(self.service_name.as_str())
+                .join(BLOB);
+
+            // Add the parent input directories to ensure they exist
+            // before adding the blobs themeselves.
+            //
+            // However, only do this work if the blobs actually exist.
+            if any_blobs {
+                inputs.0.extend(
+                    zone_get_all_parent_inputs(&dst)?
+                        .into_iter()
+                        .map(BuildInput::AddDirectory),
+                );
+            }
+
+            zone_archive_path(&dst)?
         } else {
             Utf8PathBuf::from(BLOB)
         };
-        if let Some(s3_blobs) = self.source.blobs() {
+        if let Some(s3_blobs) = s3_blobs {
...
-        if let Some(buildomat_blobs) = self.source.buildomat_blobs() {
+        if let Some(buildomat_blobs) = buildomat_blobs {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed in a0e6bbf, though I opted just to short-circuit the entire routine if there are no blobs to add. Let me know if you'd prefer an approach like the one you've outlined--I mostly went with short-circuiting because it seemed a bit sad to go through all the path computations unconditionally only to find out that we'll never use them because there's nothing to add.

zone_get_all_parent_inputs(&dst)?
.into_iter()
.map(BuildInput::AddDirectory),
);

zone_archive_path(&dst)?
} else {
Utf8PathBuf::from(BLOB)
};

if let Some(s3_blobs) = self.source.blobs() {
inputs.0.extend(s3_blobs.iter().map(|blob| {
let from = download_directory
Expand Down
Loading