Make image compression format configurable#233
Conversation
|
Thanks, looks good on a first glance but users may have download scripts which will break. I suggest to rework this to support both formats at the same time, i.e., the flag should accept a list of compression formats and then we pass |
Looking at where to best add this. Will probably update the PR tomorrow morning.
Will also update the docs. |
e8286d8 to
d80b6df
Compare
|
@pothos Updated the PR. The change adds the ability to specify multiple compression formats as a comma separated value. The compression logic was moved outside of the upload function. I also added Running: sdk@flatcar-sdk-all-3139_0_0_os-alpha-3046_0_0-107-g6d0d7ea2 ~/trunk/src/scripts $ ./image_to_vm.sh \
--upload_root rsync://ubuntu@localhost:/mnt/test_upload \
--upload \
--format openstack \
--image_compression_formats zip,gz,zstdresults in: ubuntu@flatcar:/tmp$ ls -lh /mnt/test_upload/boards/amd64-usr/3139.0.0+2022-02-21-1346/
total 2.1G
-rw-r--r-- 1 ubuntu ubuntu 1.5K Feb 23 16:35 flatcar_production_openstack.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 898M Feb 23 16:35 flatcar_production_openstack_image.img
-rw-r--r-- 1 ubuntu ubuntu 1.5K Feb 23 16:35 flatcar_production_openstack_image.img.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 406M Feb 23 16:35 flatcar_production_openstack_image.img.gz
-rw-r--r-- 1 ubuntu ubuntu 1.5K Feb 23 16:35 flatcar_production_openstack_image.img.gz.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 406M Feb 23 16:35 flatcar_production_openstack_image.img.zip
-rw-r--r-- 1 ubuntu ubuntu 1.5K Feb 23 16:35 flatcar_production_openstack_image.img.zip.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 388M Feb 23 16:35 flatcar_production_openstack_image.img.zstd
-rw-r--r-- 1 ubuntu ubuntu 1.5K Feb 23 16:35 flatcar_production_openstack_image.img.zstd.DIGESTS
|
d80b6df to
9b30ad3
Compare
|
I think we need a full test run where we compare that we still generate the same files plus two additional files |
Sounds good. Should I do that, or is there a CI that does that? Apologies, I am a newbie :D. |
We have to manually start the CI for now, will do soon :D Edit: running now http://jenkins.infra.kinvolk.io:8080/job/os/job/manifest/4937/ |
|
Something is wrong because |
|
Ah, |
Are there any CI logs I can check? The link doesn't seem to be accessible.
Ack. Looking into it now. |
9b30ad3 to
09f86d1
Compare
|
The |
|
The changed |
yup. Saw it. Testing now, but iteration time is slow :D. Will ping in the comments once done. |
|
Made some changes that also takes care of compressing updates and should handle cases where Currently, from what I see, If you prefer that I rework this a bit, let me know. Any suggestions are of course welcome. |
|
Thanks, I started a new build and will forward the results http://jenkins.infra.kinvolk.io:8080/job/os/job/manifest/4990/cldsv/ Can you have a look at the suggestions here (mainly about quoting and the changelog entry)? |
Yes. Of course! First thing in the morning. |
|
Added quotes to variables, updated changelog. I combed through the comments here, but I do not see your suggestions regarding quotes and changelog. Perhaps they were not published? |
| declare -a digest_uploads | ||
|
|
||
| for file in "${VM_GENERATED_FILES[@]}";do | ||
| if [[ "${file}" =~ \.(img|bin|vdi|vhd|vmdk)$ ]]; then |
There was a problem hiding this comment.
This duplicates the logic in compress_disk_images and I think it's better to move it there completely as suggested above
There was a problem hiding this comment.
The duplication of logic here is unfortunate, but necessary if we want to retain backwards compatibility and generate a .DIGESTS file for each archive. We need to know which files got compressed, which files are images and which files can be uploaded as is. We should always pass in images to compress_disk_images(), and expect compressed files in the results array. There is no reason to pass in any other types of files. To be honest, I think we can rename the function to compress_files() and remove the if that matches extensions. What do you think?
There needs to be a separation of concerns, and mixing files of different types leads to situations that are difficult to debug.
There was a problem hiding this comment.
Ok, this legacy logic is a bit complicated, thanks for your works there. I think it's good now, or?
There was a problem hiding this comment.
Yup. Should be ok. The changes to compress_disk_image() makes is also populate an "extra_files" array with whatever doesn't match that image pattern. Which callers can then concatenate and upload if they wish.
Oh, sorry, that was it |
41268de to
6fd38c2
Compare
|
The last completed successfully but I didn't have a close look at the list of resulting files. |
should be the same files, plus an extra For: ./image_to_vm.sh --upload_root rsync://ubuntu@localhost:/mnt/test_upload --uploadThe result in both cases (main branch and this one): ubuntu@flatcar:~/scripts$ ls -l /mnt/test_upload/boards/amd64-usr/3139.0.0+2022-03-03-1016.compress_to_image
total 381328
-rw-r--r-- 1 ubuntu ubuntu 1017 Mar 3 10:44 flatcar_production_qemu.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 535 Mar 3 10:44 flatcar_production_qemu.README
-rwxr-xr-x 1 ubuntu ubuntu 7518 Mar 3 10:44 flatcar_production_qemu.sh
-rw-r--r-- 1 ubuntu ubuntu 390453496 Mar 3 10:44 flatcar_production_qemu_image.img.bz2
-rw-r--r-- 1 ubuntu ubuntu 1017 Mar 3 10:44 flatcar_production_qemu_image.img.bz2.DIGESTS
ubuntu@flatcar:~/scripts$ ls -l /mnt/test_upload/boards/amd64-usr/3139.0.0+2022-03-03-0918.to_image/
total 381792
-rw-r--r-- 1 ubuntu ubuntu 1017 Mar 3 10:13 flatcar_production_qemu.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 535 Mar 3 10:13 flatcar_production_qemu.README
-rwxr-xr-x 1 ubuntu ubuntu 7518 Mar 3 10:13 flatcar_production_qemu.sh
-rw-r--r-- 1 ubuntu ubuntu 390928218 Mar 3 10:13 flatcar_production_qemu_image.img.bz2
-rw-r--r-- 1 ubuntu ubuntu 1017 Mar 3 10:13 flatcar_production_qemu_image.img.bz2.DIGESTSFor: ./build_image --upload_root rsync://ubuntu@localhost:/mnt/test_upload --uploadThe result for both branches: ubuntu@flatcar:~/scripts$ ls -l /mnt/test_upload/boards/amd64-usr/3139.0.0+2022-03-03-0918.bk/
total 1063860
-rw-r--r-- 1 ubuntu ubuntu 391670006 Mar 3 09:39 flatcar_production_image.bin.bz2
-rw-r--r-- 1 ubuntu ubuntu 3159 Mar 3 09:39 flatcar_production_image.bin.bz2.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 717304 Mar 3 09:39 flatcar_production_image.grub
-rw-r--r-- 1 ubuntu ubuntu 1285928 Mar 3 09:39 flatcar_production_image.shim
-rw-r--r-- 1 ubuntu ubuntu 52289048 Mar 3 09:39 flatcar_production_image.vmlinuz
-rw-r--r-- 1 ubuntu ubuntu 2306240 Mar 3 09:39 flatcar_production_image_contents.txt
-rw-r--r-- 1 ubuntu ubuntu 152830 Mar 3 09:39 flatcar_production_image_kernel_config.txt
-rw-r--r-- 1 ubuntu ubuntu 1843726 Mar 3 09:39 flatcar_production_image_licenses.json
-rw-r--r-- 1 ubuntu ubuntu 10366 Mar 3 09:37 flatcar_production_image_packages.txt
-rw-r--r-- 1 ubuntu ubuntu 20321 Mar 3 09:39 flatcar_production_image_pcr_policy.zip
-rw-r--r-- 1 ubuntu ubuntu 288111708 Mar 3 09:39 flatcar_production_update.bin.bz2
-rw-r--r-- 1 ubuntu ubuntu 345 Mar 3 09:39 flatcar_production_update.bin.bz2.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 11547194 Mar 3 09:40 flatcar_production_update.zip
-rw-r--r-- 1 ubuntu ubuntu 333 Mar 3 09:40 flatcar_production_update.zip.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 339375926 Mar 3 09:40 flatcar_test_update.gz
-rw-r--r-- 1 ubuntu ubuntu 312 Mar 3 09:40 flatcar_test_update.gz.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 185 Mar 3 09:40 version.txt
-rw-r--r-- 1 ubuntu ubuntu 279 Mar 3 09:40 version.txt.DIGESTS
ubuntu@flatcar:~/scripts$ ls -l /mnt/test_upload/boards/amd64-usr/3139.0.0+2022-03-03-1016.compress_image/
total 1061832
-rw-r--r-- 1 ubuntu ubuntu 3159 Mar 3 10:37 flatcar_production_image.bin.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 390943703 Mar 3 10:36 flatcar_production_image.bin.bz2
-rw-r--r-- 1 ubuntu ubuntu 3159 Mar 3 10:37 flatcar_production_image.bin.bz2.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 717304 Mar 3 10:36 flatcar_production_image.grub
-rw-r--r-- 1 ubuntu ubuntu 1285928 Mar 3 10:36 flatcar_production_image.shim
-rw-r--r-- 1 ubuntu ubuntu 52289048 Mar 3 10:36 flatcar_production_image.vmlinuz
-rw-r--r-- 1 ubuntu ubuntu 2306240 Mar 3 10:36 flatcar_production_image_contents.txt
-rw-r--r-- 1 ubuntu ubuntu 152830 Mar 3 10:36 flatcar_production_image_kernel_config.txt
-rw-r--r-- 1 ubuntu ubuntu 1843726 Mar 3 10:36 flatcar_production_image_licenses.json
-rw-r--r-- 1 ubuntu ubuntu 10366 Mar 3 10:35 flatcar_production_image_packages.txt
-rw-r--r-- 1 ubuntu ubuntu 20322 Mar 3 10:36 flatcar_production_image_pcr_policy.zip
-rw-r--r-- 1 ubuntu ubuntu 345 Mar 3 10:37 flatcar_production_update.bin.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 287332590 Mar 3 10:37 flatcar_production_update.bin.bz2
-rw-r--r-- 1 ubuntu ubuntu 345 Mar 3 10:37 flatcar_production_update.bin.bz2.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 11547194 Mar 3 10:38 flatcar_production_update.zip
-rw-r--r-- 1 ubuntu ubuntu 333 Mar 3 10:38 flatcar_production_update.zip.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 338802477 Mar 3 10:38 flatcar_test_update.gz
-rw-r--r-- 1 ubuntu ubuntu 312 Mar 3 10:38 flatcar_test_update.gz.DIGESTS
-rw-r--r-- 1 ubuntu ubuntu 185 Mar 3 10:38 version.txt
-rw-r--r-- 1 ubuntu ubuntu 279 Mar 3 10:38 version.txt.DIGESTSIf the CI could run all the code paths you guys usually run to properly validate that I have not missed something, that would be great. |
|
I got this error when building: (from |
Checking. Will update today. Thanks for the debug output! |
|
@pothos any chance there's a guide on how to set up a 3rd party CI that can mirror yours? I'd like to set one up to not have to bug you. |
|
At the moment we have two setups, one is the inherited using cork, and the new one uses the run_sdk_container script for Docker. The failure happened with the new setup - while not complete I'll attach the Jenkins files here: |
Thanks! Currently adding a function for the legacy digests, testing locally and pushing. I managed to run |
This change adds a new flag called --image_compression_format which allows us to output the final VM image as one of the supported formats: bz2 (default), gz, zip or none if the compression format is "none" or "", the image will not be compressed. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This change makes the Jenkins job output openstack images using gzip compression format. This allows OpenStack users to directly consume images by simply specifying the URL to the image. Glance will then download the image, unarchive it and add it to it's catalogue. Fixes flatcar#575 Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
Add the ability to specify a comma separated list of compression formats. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
a514639 to
f126deb
Compare
|
Updated the PR. If you could share the error from the previous failure, that would be great. |
|
I think it worked now! There was a just build failure on arm64 which may be due to needing a rebase. |
b17d52c to
71e4f1c
Compare
I rebased on top of main, and squashed most of the commits. Give it another go. Running it locally as well. |
|
arm64 is currently failing due to an issue that im fixing here: flatcar-archive/coreos-overlay#1690. |
Rename sztd to zst and amend the changelog. The zstd binary generates a compressed file with the .zst extension by default. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
1d8f850 to
e88f12c
Compare
pothos
left a comment
There was a problem hiding this comment.
Started another test but I think all is covered now, thanks
|
(While at it we can also add a gz image for DigitalOcean to address the temporary failures the note in https://www.flatcar.org/docs/latest/installing/cloud/digitalocean/ talks about) |
Co-authored-by: Kai Lüke <pothos@users.noreply.github.com>
Co-authored-by: Kai Lüke <pothos@users.noreply.github.com>
|
Thanks again :) |
My pleasure! Thank you for the guidance and patience! :D |
|
It has been working well so far in Beta and Alpha releases. I'll pick it for the Stable/LTS branches to reduce the build system differences across the branches. |
Make image compression format configurable
Make image compression format configurable
Make image compression format configurable
This change adds a new flag called --image_compression_format which allows us to output the final VM image as one of the supported formats: bz2 (default), gz, zip or none
If the compression format is "none" or "", the image will not be compressed.
This change also enables the CI to output OpenStack images using
gzipcompression instead ofbz2.Fixes flatcar/Flatcar#575
How to use
Simply add
--image_compression_format=gzwhen callingimage_to_vm.sh. Leaving this option unset will preserve the current behavior.Testing done
These changes were tested by specifying all supported formats as well as arbitrary bogus strings. The results were as expected. Success on any of the supported formats, error on anything else. Image archive as well as legacy digest files were properly generated.
changelog/directory (user-facing change, bug fix, security fix, update)