From a45a0eefe864b760b634a7e673bad0068b4fb3b6 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Fri, 7 Jun 2024 11:14:09 -0400 Subject: [PATCH] Use cloud images as base Signed-off-by: Mohammed Naser --- magnum_cluster_api/cmd/image_builder.py | 93 +++++++------------------ zuul.d/playbooks/image-build/run.yml | 2 + 2 files changed, 29 insertions(+), 66 deletions(-) diff --git a/magnum_cluster_api/cmd/image_builder.py b/magnum_cluster_api/cmd/image_builder.py index d341a293..d5e46359 100644 --- a/magnum_cluster_api/cmd/image_builder.py +++ b/magnum_cluster_api/cmd/image_builder.py @@ -35,6 +35,7 @@ QEMU_PACKAGES = [ "qemu-kvm", "qemu-utils", + "mkisofs", ] @@ -66,7 +67,7 @@ def validate_version(_, __, value): @click.option( "--image-builder-version", show_default=True, - default="v0.1.29", + default="3f350a5bc1f8e9ecbf25a1f119d14a5d847058df", # https://github.com/kubernetes-sigs/image-builder/pull/1485 help="Image builder tag (or commit) to use for building image", ) @click.option( @@ -164,70 +165,30 @@ def main( "node_custom_roles_pre": f"{node_custom_roles_pre}", } - # NOTE(mnaser): We use the latest tested daily ISO for Ubuntu 22.04 in order - # to avoid a lengthy upgrade process. - - # NOTE(jrosser): This can be uncommented again when - # https://github.com/vexxhost/magnum-cluster-api/issues/378 is fixed - # if operating_system == "ubuntu-2204": - # iso = "jammy-live-server-amd64.iso" - # - # customization["iso_url"] = ( - # f"http://cdimage.ubuntu.com/ubuntu-server/jammy/daily-live/current/{iso}" - # ) - # - # # Get the SHA256 sum for the ISO - # r = requests.get( - # "http://cdimage.ubuntu.com/ubuntu-server/jammy/daily-live/current/SHA256SUMS" - # ) - # r.raise_for_status() - # for line in r.text.splitlines(): - # if iso in line: - # customization["iso_checksum"] = line.split()[0] - # break - # - # # Assert that we have the checksum - # assert "iso_checksum" in customization - - if operating_system == "rockylinux-8": - iso = "Rocky-x86_64-minimal.iso" - - customization["iso_url"] = ( - f"https://download.rockylinux.org/pub/rocky/8/isos/x86_64/{iso}" - ) - - # Get the SHA256 sum for the ISO - r = requests.get( - "https://download.rockylinux.org/pub/rocky/8/isos/x86_64/Rocky-x86_64-minimal.iso.CHECKSUM" - ) - r.raise_for_status() - for line in r.text.splitlines(): - if iso in line and "SHA256" in line: - customization["iso_checksum"] = line.split()[3] - break - - # Assert that we have the checksum - assert "iso_checksum" in customization - - if operating_system == "rockylinux-9": - iso = "Rocky-x86_64-minimal.iso" - - customization["iso_url"] = ( - f"https://download.rockylinux.org/pub/rocky/9/isos/x86_64/{iso}" - ) - - # Get the SHA256 sum for the ISO - r = requests.get( - "https://download.rockylinux.org/pub/rocky/9/isos/x86_64/Rocky-x86_64-minimal.iso.CHECKSUM" - ) - r.raise_for_status() - for line in r.text.splitlines(): - if iso in line and "SHA256" in line: - customization["iso_checksum"] = line.split()[3] - break - - # Assert that we have the checksum - assert "iso_checksum" in customization + # NOTE(mnaser): Inside our CI, we use a local image in order speed up the + # process, so we will not download the image from the internet. + if os.environ.get("CI") == "true": + if operating_system == "ubuntu-2204": + customization["iso_checksum"] = ( + "https://static.atmosphere.dev/ubuntu/jammy/20240605.1/SHA256SUMS" + ) + customization["iso_url"] = ( + "https://static.atmosphere.dev/ubuntu/jammy/20240605.1/jammy-server-cloudimg-amd64.img" + ) + elif operating_system == "rockylinux-8": + customization["iso_checksum"] = ( + "https://static.atmosphere.dev/rocky/8/images/x86_64/CHECKSUM" + ) + customization["iso_url"] = ( + "https://static.atmosphere.dev/rocky/8/images/x86_64/Rocky-8-GenericCloud-Base.latest.x86_64.qcow2" + ) + elif operating_system == "rockylinux-9": + customization["iso_checksum"] = ( + "https://static.atmosphere.dev/rocky/9/images/x86_64/CHECKSUM" + ) + customization["iso_url"] = ( + "https://static.atmosphere.dev/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2" + ) # NOTE(mnaser): Let's set number of CPUs to equal the number of CPUs on the # host to speed up the build process. @@ -258,7 +219,7 @@ def main( /usr/bin/make \ -C \ {ib_path}/images/capi \ - build-qemu-{operating_system} + build-qemu-{operating_system}-cloudimg """ ).encode("utf-8"), env={ diff --git a/zuul.d/playbooks/image-build/run.yml b/zuul.d/playbooks/image-build/run.yml index e3923b0f..82db599f 100644 --- a/zuul.d/playbooks/image-build/run.yml +++ b/zuul.d/playbooks/image-build/run.yml @@ -16,3 +16,5 @@ shell: "$HOME/.local/bin/magnum-cluster-api-image-builder --operating-system {{ image_operating_system }} --version {{ kube_tag }}" args: chdir: "{{ zuul_output_dir }}/artifacts" + environment: + CI: "true"