Backport patches to fix GCE image format not to be 'docker'

(cherry picked from commit 80ddc0cf015d582ca21376c3ba97b38ba813f5e2)
This commit is contained in:
Adam Williamson 2024-10-07 20:48:47 +03:00 committed by Stepan Oksanichenko
parent b3b4b894c7
commit 2495771f59
3 changed files with 215 additions and 41 deletions

View File

@ -1,41 +0,0 @@
From 432b0bce0401c4bbcd1a958a89305c475a794f26 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Jan 19 2024 07:25:09 +0000
Subject: checks: don't require "repo" in the "ostree" schema
Per @siosm in https://pagure.io/pungi-fedora/pull-request/1227
this option "is deprecated and not needed anymore", so Pungi
should not be requiring it.
Merges: https://pagure.io/pungi/pull-request/1714
Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
diff --git a/pungi/checks.py b/pungi/checks.py
index a340f93..db8b297 100644
--- a/pungi/checks.py
+++ b/pungi/checks.py
@@ -1066,7 +1066,6 @@ def make_schema():
"required": [
"treefile",
"config_url",
- "repo",
"ostree_repo",
],
"additionalProperties": False,
diff --git a/pungi/phases/ostree.py b/pungi/phases/ostree.py
index 90578ae..2649cdb 100644
--- a/pungi/phases/ostree.py
+++ b/pungi/phases/ostree.py
@@ -85,7 +85,7 @@ class OSTreeThread(WorkerThread):
comps_repo = compose.paths.work.comps_repo(
"$basearch", variant=variant, create_dir=False
)
- repos = shortcuts.force_list(config["repo"]) + self.repos
+ repos = shortcuts.force_list(config.get("repo", [])) + self.repos
if compose.has_comps:
repos.append(translate_path(compose, comps_repo))
repos = get_repo_dicts(repos, logger=self.pool)

211
1788.patch Normal file
View File

@ -0,0 +1,211 @@
From 5338d3098ccd614a8fd32f837a393aed78b471bd Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Sep 20 2024 06:03:15 +0000
Subject: [PATCH 1/2] move osbuild/kiwi-specific EXTENSIONS to each phase
The image-build phase's EXTENSIONS dict is meant to exactly
mirror the 'formats' that exist in the context of the command
`koji image-build`, which is driven by this phase. That nice
association was lost, however, by adding a couple of items to it
which exist for the purposes of the osbuild phase (and in the
case of .iso, also the kiwibuild phase), which import this dict
and uses it for image identification.
To make the association 1:1 again and more clearly show what's
going on here, let's move those entries out into the osbuild and
kiwi phases. osbuild now has its own dict which starts out as a
copy of the image-build one before being extended. And let's
update the relevant comments.
Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
diff --git a/pungi/phases/image_build.py b/pungi/phases/image_build.py
index cb76c1a..cd034cd 100644
--- a/pungi/phases/image_build.py
+++ b/pungi/phases/image_build.py
@@ -22,10 +22,13 @@ from productmd.rpms import Rpms
# This is a mapping from formats to file extensions. The format is what koji
# image-build command expects as argument, and the extension is what the file
# name will be ending with. The extensions are used to filter out which task
-# results will be pulled into the compose.
+# results will be pulled into the compose. This dict is also used later in
+# the process to set the image 'type' in productmd metadata terms - the type
+# is set as the first key in this dict which has the file's extension in its
+# values. This dict is imported and extended for similar purposes by other
+# phases (at least osbuild and kiwibuild).
EXTENSIONS = {
"docker": ["tar.gz", "tar.xz"],
- "iso": ["iso"],
"liveimg-squashfs": ["liveimg.squashfs"],
"qcow": ["qcow"],
"qcow2": ["qcow2"],
@@ -40,7 +43,6 @@ EXTENSIONS = {
"vdi": ["vdi"],
"vmdk": ["vmdk"],
"vpc": ["vhd"],
- "vhd-compressed": ["vhd.gz", "vhd.xz"],
"vsphere-ova": ["vsphere.ova"],
}
diff --git a/pungi/phases/kiwibuild.py b/pungi/phases/kiwibuild.py
index bb26812..15732ce 100644
--- a/pungi/phases/kiwibuild.py
+++ b/pungi/phases/kiwibuild.py
@@ -15,6 +15,10 @@ KIWIEXTENSIONS = [
("vhd-compressed", ["vhdfixed.xz"], "vhd.xz"),
("vagrant-libvirt", ["vagrant.libvirt.box"], "vagrant-libvirt.box"),
("vagrant-virtualbox", ["vagrant.virtualbox.box"], "vagrant-virtualbox.box"),
+ # .iso images can be of many types - boot, cd, dvd, live... -
+ # so 'boot' is just a default guess. 'iso' is not a valid
+ # productmd image type
+ ("boot", [".iso"], "iso"),
]
diff --git a/pungi/phases/osbuild.py b/pungi/phases/osbuild.py
index 6c5b7e5..a3b5c9b 100644
--- a/pungi/phases/osbuild.py
+++ b/pungi/phases/osbuild.py
@@ -11,6 +11,16 @@ from ..linker import Linker
from ..wrappers import kojiwrapper
from .image_build import EXTENSIONS
+# copy and modify EXTENSIONS with some that osbuild produces but which
+# do not exist as `koji image-build` formats
+OSBUILDEXTENSIONS = EXTENSIONS.copy()
+OSBUILDEXTENSIONS.update(
+ {
+ "iso": ["iso"],
+ "vhd-compressed": ["vhd.gz", "vhd.xz"],
+ }
+)
+
class OSBuildPhase(
base.PhaseLoggerMixin, base.ImageConfigMixin, base.ConfigGuardedPhase
@@ -203,7 +213,7 @@ class RunOSBuildThread(WorkerThread):
# architecture, but we don't verify that.
build_info = koji.koji_proxy.getBuild(build_id)
for archive in koji.koji_proxy.listArchives(buildID=build_id):
- if archive["type_name"] not in EXTENSIONS:
+ if archive["type_name"] not in OSBUILDEXTENSIONS:
# Ignore values that are not of required types.
continue
@@ -241,7 +251,7 @@ class RunOSBuildThread(WorkerThread):
linker.link(src_file, image_dest, link_type=compose.conf["link_type"])
- for suffix in EXTENSIONS[archive["type_name"]]:
+ for suffix in OSBUILDEXTENSIONS[archive["type_name"]]:
if archive["filename"].endswith(suffix):
break
else:
From 739062ed3c471e74ba9c5144c4047f67f9fbe8c8 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Sep 20 2024 06:03:58 +0000
Subject: [PATCH 2/2] image_build: drop .tar.gz as an expected extension for docker
Koji's image-build command has not been capable of producing a
docker image with .tar.gz as its extension since 2015:
https://pagure.io/koji/c/b489f282bee7a008108534404dd2e78efb2256e7?branch=master
as that commit message implies, the files have not actually been
gzip-compressed for even longer:
https://pagure.io/koji/c/82a405c7943192e3bba3340efe7a8d07a0e26b70?branch=master
so there's no point to having this any more. It is causing the
wrong productmd 'type' to be set for GCE cloud images, which *do*
have the .tar.gz extension - because docker appears in this dict
before tar-gz, their type is being set as 'docker' not 'tar-gz'.
Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
diff --git a/pungi/phases/image_build.py b/pungi/phases/image_build.py
index cd034cd..c28ccc2 100644
--- a/pungi/phases/image_build.py
+++ b/pungi/phases/image_build.py
@@ -28,7 +28,7 @@ from productmd.rpms import Rpms
# values. This dict is imported and extended for similar purposes by other
# phases (at least osbuild and kiwibuild).
EXTENSIONS = {
- "docker": ["tar.gz", "tar.xz"],
+ "docker": ["tar.xz"],
"liveimg-squashfs": ["liveimg.squashfs"],
"qcow": ["qcow"],
"qcow2": ["qcow2"],
diff --git a/tests/test_imagebuildphase.py b/tests/test_imagebuildphase.py
index 90f10ef..895f040 100644
--- a/tests/test_imagebuildphase.py
+++ b/tests/test_imagebuildphase.py
@@ -846,12 +846,12 @@ class TestCreateImageBuildThread(PungiTestCase):
"amd64": [
"/koji/task/1235/tdl-amd64.xml",
"/koji/task/1235/Fedora-Docker-Base-20160103.amd64.qcow2",
- "/koji/task/1235/Fedora-Docker-Base-20160103.amd64.tar.gz",
+ "/koji/task/1235/Fedora-Docker-Base-20160103.amd64.tar.xz",
],
"x86_64": [
"/koji/task/1235/tdl-x86_64.xml",
"/koji/task/1235/Fedora-Docker-Base-20160103.x86_64.qcow2",
- "/koji/task/1235/Fedora-Docker-Base-20160103.x86_64.tar.gz",
+ "/koji/task/1235/Fedora-Docker-Base-20160103.x86_64.tar.xz",
],
}
@@ -896,9 +896,9 @@ class TestCreateImageBuildThread(PungiTestCase):
link_type="hardlink-or-copy",
),
mock.call.link(
- "/koji/task/1235/Fedora-Docker-Base-20160103.amd64.tar.gz",
+ "/koji/task/1235/Fedora-Docker-Base-20160103.amd64.tar.xz",
self.topdir
- + "/compose/Client/amd64/images/Fedora-Docker-Base-20160103.amd64.tar.gz", # noqa: E501
+ + "/compose/Client/amd64/images/Fedora-Docker-Base-20160103.amd64.tar.xz", # noqa: E501
link_type="hardlink-or-copy",
),
mock.call.link(
@@ -908,9 +908,9 @@ class TestCreateImageBuildThread(PungiTestCase):
link_type="hardlink-or-copy",
),
mock.call.link(
- "/koji/task/1235/Fedora-Docker-Base-20160103.x86_64.tar.gz",
+ "/koji/task/1235/Fedora-Docker-Base-20160103.x86_64.tar.xz",
self.topdir
- + "/compose/Client/x86_64/images/Fedora-Docker-Base-20160103.x86_64.tar.gz", # noqa: E501
+ + "/compose/Client/x86_64/images/Fedora-Docker-Base-20160103.x86_64.tar.xz", # noqa: E501
link_type="hardlink-or-copy",
),
],
@@ -922,8 +922,8 @@ class TestCreateImageBuildThread(PungiTestCase):
"type": "qcow2",
"arch": "amd64",
},
- "image_dir/Client/amd64/Fedora-Docker-Base-20160103.amd64.tar.gz": {
- "format": "tar.gz",
+ "image_dir/Client/amd64/Fedora-Docker-Base-20160103.amd64.tar.xz": {
+ "format": "tar.xz",
"type": "docker",
"arch": "amd64",
},
@@ -932,8 +932,8 @@ class TestCreateImageBuildThread(PungiTestCase):
"type": "qcow2",
"arch": "x86_64",
},
- "image_dir/Client/x86_64/Fedora-Docker-Base-20160103.x86_64.tar.gz": {
- "format": "tar.gz",
+ "image_dir/Client/x86_64/Fedora-Docker-Base-20160103.x86_64.tar.xz": {
+ "format": "tar.xz",
"type": "docker",
"arch": "x86_64",
},

View File

@ -10,6 +10,7 @@ URL: https://pagure.io/pungi
Source0: %{name}-%{version}.tar.bz2
Patch: https://pagure.io/pungi/pull-request/1780.patch
Patch: https://pagure.io/pungi/pull-request/1782.patch
Patch: https://pagure.io/pungi/pull-request/1788.patch
BuildRequires: make
BuildRequires: python3-pytest
@ -176,6 +177,9 @@ rm %{buildroot}%{_bindir}/pungi
%{_bindir}/%{name}-cache-cleanup
%changelog
* Mon Oct 07 2024 Adam Williamson <awilliam@redhat.com> - 4.7.0-4
- Backport patches to fix GCE image format not to be 'docker'
* Mon Sep 1 2025 Aleksandra Kachanova <akachanova@almalinux.org> - 4.7.0-7
- Add riscv64 to the list of supported architectures