Skip to content

ensure blob directory exists in archives #77

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

Merged
merged 2 commits into from
Apr 28, 2025

Conversation

gjcolombo
Copy link
Contributor

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).

@gjcolombo gjcolombo requested a review from smklein April 28, 2025 19:12
@gjcolombo
Copy link
Contributor Author

Whoops. Will look at the test failures when I get a minute.

.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.

@gjcolombo gjcolombo merged commit ec49f47 into oxidecomputer:main Apr 28, 2025
5 checks passed
@gjcolombo
Copy link
Contributor Author

Thanks for the fast turnaround, @smklein!

@gjcolombo gjcolombo deleted the gjcolombo/blob-dir-in-archive branch April 28, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants