#1658 image-build/osbuild: Pull ISOs into the compose
Merged 2 years ago by lsedlar. Opened 2 years ago by lsedlar.
lsedlar/pungi pull-osbuild-made-isos  into  master

@@ -25,6 +25,7 @@ 

  # results will be pulled into the compose.

  EXTENSIONS = {

      "docker": ["tar.gz", "tar.xz"],

+     "iso": ["iso"],

      "liveimg-squashfs": ["liveimg.squashfs"],

      "qcow": ["qcow"],

      "qcow2": ["qcow2"],

file modified
+13 -5
@@ -212,10 +212,18 @@ 

              # image_dir is absolute path to which the image should be copied.

              # We also need the same path as relative to compose directory for

              # including in the metadata.

-             image_dir = compose.paths.compose.image_dir(variant) % {"arch": arch}

-             rel_image_dir = compose.paths.compose.image_dir(variant, relative=True) % {

-                 "arch": arch

-             }

+             if archive["type_name"] == "iso":

+                 # If the produced image is actually an ISO, it should go to

+                 # iso/ subdirectory.

+                 image_dir = compose.paths.compose.iso_dir(arch, variant)

+                 rel_image_dir = compose.paths.compose.iso_dir(

+                     arch, variant, relative=True

+                 )

+             else:

+                 image_dir = compose.paths.compose.image_dir(variant) % {"arch": arch}

+                 rel_image_dir = compose.paths.compose.image_dir(

+                     variant, relative=True

+                 ) % {"arch": arch}

              util.makedirs(image_dir)

  

              image_dest = os.path.join(image_dir, archive["filename"])
@@ -238,7 +246,7 @@ 

  

              # Update image manifest

              img = Image(compose.im)

-             img.type = archive["type_name"]

+             img.type = archive["type_name"] if archive["type_name"] != "iso" else "dvd"

              img.format = suffix

              img.path = os.path.join(rel_image_dir, archive["filename"])

              img.mtime = util.get_mtime(image_dest)

OSBuild tasks can produce ISO files. If they do, we should include them in the compose, and we should pull them into the iso/ subdirectory together with other ISOs.

Fixes: #1657

rebased onto eac36e36c8485afab54827d237559dc24ee2f0da

2 years ago

@pwhalen , @obudai , I'm not sure I have a good way to test this code. Would you be able to test if I provided you with a scratch build? (For which release should it be?)

LGTM, and thank you for working on this. I can test a scratch build - the compose box is F36.

This mostly worked after fixing a small typo. It does hit an unexpected image type at the end:

Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/pungi/scripts/pungi_koji.py", line 670, in cli_main
main()
File "/usr/lib/python3.10/site-packages/pungi/scripts/pungi_koji.py", line 347, in main
run_compose(
File "/usr/lib/python3.10/site-packages/pungi/scripts/pungi_koji.py", line 562, in run_compose
compose.im.dump(compose.paths.compose.metadata("images.json"))
File "/usr/lib/python3.10/site-packages/productmd/common.py", line 288, in dump
self.serialize(parser)
File "/usr/lib/python3.10/site-packages/productmd/images.py", line 150, in serialize
image_obj.serialize(images)
File "/usr/lib/python3.10/site-packages/productmd/images.py", line 310, in serialize
self.validate()
File "/usr/lib/python3.10/site-packages/productmd/common.py", line 249, in validate
method()
File "/usr/lib/python3.10/site-packages/productmd/images.py", line 269, in _validate_type
self._assert_value("type", SUPPORTED_IMAGE_TYPES)
File "/usr/lib/python3.10/site-packages/productmd/common.py", line 215, in _assert_value
raise ValueError("%s: Field '%s' has invalid value: %s" % (self.class.name, field, value))
ValueError: Image: Field 'type' has invalid value: iso

The compose is marked doomed, but the iso is in the right directory.

rebased onto 8920eef

2 years ago

That's a problem with metadata. Patch is updated, here's a new scratch build:
https://koji.fedoraproject.org/koji/taskinfo?taskID=98353490

That's a problem with metadata. Patch is updated, here's a new scratch build:
https://koji.fedoraproject.org/koji/taskinfo?taskID=98353490

Thanks, that worked as expected for todays compose.

Thanks for confirmation.
It's not an ideal solution. Productmd has different types for DVD and DVD with ostree payload. However, there's no good way to distinguish what osbuild actually creates, so falling back on the more generic DVD is probably the best we can reasonably do here.

Pull-Request has been merged by lsedlar

2 years ago

@lsedlar in case of osbuild, it depends on which image type you request, should be hard to write the logic, happy to help.

Yes, it's possible to write a mapping from osbuild type to what should be in metadata. I'm not convinced this is really required though. I really do not want to maintain yet another mapping. That's historically been a recipe for pain. The current status is not really wrong, so unless someone comes to complain, I'd keep it the way it is.

Makes sense. Feel free to reach out to me if someone does.