From b4ebca61cc7ccbea6d0990673d630575c4707c96 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 10 Oct 2025 09:29:23 -0700 Subject: [PATCH] Allow disabling compression of uploaded images This may not be required for openstack, but let's maintain parity between the swift and s3 upload roles. Change-Id: I3740528d90b27ca36d742b6069014a395252a1f3 Co-Authored-By: Simon Westphahl --- roles/upload-image-swift/README.rst | 12 ++++++- roles/upload-image-swift/defaults/main.yaml | 1 + roles/upload-image-swift/tasks/main.yaml | 36 ++++++++++++--------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/roles/upload-image-swift/README.rst b/roles/upload-image-swift/README.rst index 76b6cdbee..969f45f80 100644 --- a/roles/upload-image-swift/README.rst +++ b/roles/upload-image-swift/README.rst @@ -4,7 +4,8 @@ This uploads a filesystem image (for example, one built by diskimage builder) to an OpenStack Object Store (Swift) container. The role returns an artifact to Zuul suitable for use by the zuul-launcher. -If a `raw` or `vhd` image is provided and the `zstd` command is +If a `raw` or `vhd` image is provided, +`upload_image_swift_compress_image` is true and the `zstd` command is available, it will be compressed in the way that zuul-launcher expects. @@ -61,6 +62,15 @@ expects. The object name to use when uploading. +.. zuul:rolevar:: upload_image_swift_compress_image + :default: true + + Whether to compress the image using zstd before upload. + + Some providers may require the image to be in raw format when + importing directly from object storage. In those cases the flag + should be set to `false`. + .. zuul:rolevar:: upload_image_swift_hash_timeout :default: 600 diff --git a/roles/upload-image-swift/defaults/main.yaml b/roles/upload-image-swift/defaults/main.yaml index 044d22bd0..907d0440e 100644 --- a/roles/upload-image-swift/defaults/main.yaml +++ b/roles/upload-image-swift/defaults/main.yaml @@ -3,4 +3,5 @@ upload_image_swift_delete_after: 0 upload_image_swift_filename: '{{ build_diskimage_image_root }}/{{ build_diskimage_image_name }}.{{ upload_image_swift_extension }}' upload_image_swift_name: '{{ zuul.build }}-{{ build_diskimage_image_name }}.{{ upload_image_swift_extension }}' upload_image_swift_extension: '{{ upload_image_swift_format }}' +upload_image_swift_compress_image: true upload_image_swift_hash_timeout: 600 diff --git a/roles/upload-image-swift/tasks/main.yaml b/roles/upload-image-swift/tasks/main.yaml index cab9b860b..42b75c7de 100644 --- a/roles/upload-image-swift/tasks/main.yaml +++ b/roles/upload-image-swift/tasks/main.yaml @@ -15,27 +15,31 @@ poll: 0 register: md5_task -- name: Check if zstd is installed - shell: "command -v zstd || exit 1" - register: zstd_installed - failed_when: false - -- name: Compress image - when: - - "zstd_installed.rc == 0" - - "upload_image_swift_format in ['raw', 'vhd']" - command: zstd '{{ upload_image_swift_filename }}' - - name: Set extension set_fact: zj_upload_image_swift_extension: '' -- name: Set extension +- name: Compress image when: - - "zstd_installed.rc == 0" - - "upload_image_swift_format in ['raw', 'vhd']" - set_fact: - zj_upload_image_swift_extension: '.zst' + - "upload_image_swift_compress_image" + block: + - name: Check if zstd is installed + shell: "command -v zstd || exit 1" + register: zstd_installed + failed_when: false + + - name: Compress image + when: + - "zstd_installed.rc == 0" + - "upload_image_swift_format in ['raw', 'vhd']" + command: zstd '{{ upload_image_swift_filename }}' + + - name: Set extension + when: + - "zstd_installed.rc == 0" + - "upload_image_swift_format in ['raw', 'vhd']" + set_fact: + zj_upload_image_swift_extension: '.zst' - name: Upload image to swift upload_image_swift: