Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow uploading the latest image under a common name #858

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions jenkins/image_building/upload-ci-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -eux

COMMON_IMAGE_NAME="metal3-ci-${IMAGE_OS}-latest"

delete_old_images() {

# We keep last RETENTION_NUM of metal3ci images and delete old ones when new image has been pushed
Expand Down Expand Up @@ -47,7 +49,17 @@ upload_ci_image_cleura() {
export OS_AUTH_VERSION=3
export OS_IDENTITY_API_VERSION=3

openstack image create "${img_name}" --file "${img_name}".qcow2 --disk-format=qcow2
# Check if the common image already exists
if openstack image show "${COMMON_IMAGE_NAME}" &>/dev/null; then
# Get the original name of the current common image
original_name=$(openstack image show -f value -c properties "${COMMON_IMAGE_NAME}" | grep image_name | cut -d'=' -f2)
# Rename the existing common image back to its original name
openstack image set --name "${original_name}" "${COMMON_IMAGE_NAME}"
fi

# Create the new image with the common name
openstack image create "${COMMON_IMAGE_NAME}" --file "${img_name}".qcow2 --disk-format=qcow2 --property image_name="${img_name}"

# delete old images (keeps latest five)
delete_old_images

Expand All @@ -68,8 +80,18 @@ upload_ci_image_xerces() {
export OS_USER_DOMAIN_NAME="xerces"
export OS_IDENTITY_API_VERSION=3

# Check if the common image already exists
if openstack image show "${COMMON_IMAGE_NAME}" &>/dev/null; then
Rozzii marked this conversation as resolved.
Show resolved Hide resolved
# Get the original name of the current common image
original_name=$(openstack image show -f value -c properties "${COMMON_IMAGE_NAME}" | grep image_name | cut -d'=' -f2)
# Rename the existing common image back to its original name
openstack image set --name "${original_name}" "${COMMON_IMAGE_NAME}"
fi

qemu-img convert -f qcow2 -O raw "${img_name}".qcow2 "${img_name}".raw
openstack image create "${img_name}" --file "${img_name}".raw --disk-format=raw

# Create the new image with the common name
openstack image create "${COMMON_IMAGE_NAME}" --file "${img_name}".raw --disk-format=raw --property image_name="${img_name}"

# delete old images (keeps latest five)
delete_old_images
Expand Down
Loading