Improve testability and robustness for get-openstack-images
What does this MR do and why?
This MR aims to fix issues addressed in #951 (closed):
- add a manifest pull when image is found in Glance for the sake of testing
- If image is found in Glance, do a properties update anyway to ensure we have everything up to date
- move
tagtocreate_imagecall to avoid issues when it would break between the image push and tag part, resulting in an image being pushed without the proper tag set up which can lead to duplicate images. - minor code cleanups
2024-02-08 11:29:52,956 INFO __main__ <module>: Working on image: ubuntu-jammy-plain-rke2-1-26-9 with MD5 checksum 4ce2a9b432c8dcaf1f9dc832dd8c6899
2024-02-08 11:29:53,966 WARNING __main__ image_exists_in_glance: Image with name 'ubuntu-jammy-plain-rke2-1-26-9' already exists.
2024-02-08 11:29:53,966 INFO __main__ <module>: Image already in Glance: ubuntu-jammy-plain-rke2-1-26-9 with MD5 checksum 4ce2a9b432c8dcaf1f9dc832dd8c6899
2024-02-08 11:29:53,966 INFO __main__ <module>: Existing image details - Name: ubuntu-jammy-plain-rke2-1-26-9, UUID: b6c9485e-09cb-4df4-9c60-ee30f5d26fec
2024-02-08 11:29:54,810 INFO __main__ <module>: Updating image properties in Glance...
2024-02-08 11:29:54,810 INFO __main__ push_image_to_glance: Updating image properties for image ID b6c9485e-09cb-4df4-9c60-ee30f5d26fec with tag sylva-md5-4ce2a9b432c8dcaf1f9dc832dd8c6899...
2024-02-08 11:29:54,810 INFO __main__ push_image_to_glance: Updating image properties...
2024-02-08 11:29:54,810 INFO __main__ push_image_to_glance: Image properties to update: {'archive-size': '1939490553', 'compression': 'gz', 'filename': 'ubuntu-jammy-plain-rke2-1.26.9.raw', 'flavor': 'plain', 'image-format': 'raw', 'k8s-flavor': 'rke2test', 'k8s-version': '1.26.9-rke2r1', 'md5': '4ce2a9b432c8dcaf1f9dc832dd8c6899', 'os': 'ubuntu', 'os-release': 'jammy', 'sha256': 'aa729d07a5957dfc30f50ca762c08701fbf9785fafa9e72938ec151ab5cb8c49', '_size': '6207111168', 'uri': 'oci://registry.gitlab.com/sylva-projects/sylva-elements/diskimage-builder/ubuntu-jammy-plain-rke2-1.26.9:0.1.7', 'owner_specified.openstack.md5': '4ce2a9b432c8dcaf1f9dc832dd8c6899'}
2024-02-08 11:29:54,932 INFO __main__ <module>: Image properties updated for image ID b6c9485e-09cb-4df4-9c60-ee30f5d26fec
2024-02-08 11:29:54,932 INFO __main__ <module>: Finished processing image: ubuntu-jammy-plain-rke2-1-26-9
2024-02-08 11:29:54,933 INFO __main__ <module>: Images UUID map:
{'ubuntu-jammy-plain-rke2-1-26-9': {'openstack_glance_uuid': 'b6c9485e-09cb-4df4-9c60-ee30f5d26fec'}}
2024-02-08 11:29:54,933 INFO __main__ <module>: Pushing ConfigMap to Kubernetes...
2024-02-08 11:29:54,970 INFO __main__ create_or_update_configmap: ConfigMap updated. Name: openstack-images-uuids
2024-02-08 11:29:54,970 INFO __main__ <module>: We're done
Related reference(s)
Test coverage
Edited by Mihai Zaharia