Skip to content

Conversation

JackPGreen
Copy link
Collaborator

@JackPGreen JackPGreen commented Sep 3, 2025

Simplify

The script calls functions in order, most steps only proceed if a certain condition is met. The subsequent step then immediately checks the same condition before proceeding which is redundant.

This is an optimization, it's not a problem.

Example:
wait_for_container_scan:

elif [[ ${SCAN_STATUS} == "completed" && "${IMAGE_CERTIFIED}" == "true" ]]; then
echo "Scan passed!" ; return 0
Immediately followed by publish_the_image:
if [[ ${SCAN_STATUS} != "completed" || "${IMAGE_CERTIFIED}" != "true" ]]; then
echoerr "Image you are trying to publish did not pass the certification test, its status is \"${SCAN_STATUS}\" and certified is \"${IMAGE_CERTIFIED}\""
return 1
fi

wait_for_container_publish:

IMAGE=$(get_image published)
IS_PUBLISHED=$(echo "${IMAGE}" | jq -r '.total')
if [[ ${IS_PUBLISHED} == "1" ]]; then
echo "Image is published, exiting."
return 0
else
echo "Image is still not published, waiting..."
fi
Immediately followed by sync_tags:
IMAGE=$(get_image published)
IMAGE_EXISTS=$(echo "${IMAGE}" | jq -r '.total')
if [[ ${IMAGE_EXISTS} == "0" ]]; then
echo "Image you are trying to sync does not exist."
return 1
fi

Finally merged publish_the_image & sync_tags functions as now they are the same.

get_image

get_image took in filter parameters (e.g. deleted, published), because prior to #968, it was filtering by image name and multiple results were expected.

Now that we use IMAGE_ID, there should only be one response.

This also means rather than filtering published on the server-side, we can get the image and check the published status of the response - which allows us to log it for debug purposes.

wait_for_container_publish

In the event of a timeout waiting for a publish, we log the test results since #845
We should also add information on the status of the (publish) request, as this is what helped us identify the root cause of the RedHat publish issues

@JackPGreen JackPGreen self-assigned this Sep 3, 2025
@JackPGreen JackPGreen requested a review from a team as a code owner September 3, 2025 09:39
@JackPGreen JackPGreen force-pushed the simplify-`publish-rhel.sh` branch from 48b52be to 3efdd3e Compare September 3, 2025 09:43
@JackPGreen JackPGreen force-pushed the simplify-`publish-rhel.sh` branch from 3efdd3e to b6893b5 Compare September 3, 2025 09:52
Copy link
Contributor

@nishaatr nishaatr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change!

@JackPGreen JackPGreen changed the title Simplify publish-rhel.sh Refactor publish-rhel.sh Sep 4, 2025
@JackPGreen JackPGreen force-pushed the simplify-`publish-rhel.sh` branch 2 times, most recently from b9540cc to 7688f53 Compare September 4, 2025 22:38
@JackPGreen JackPGreen requested a review from nishaatr September 4, 2025 22:38
@JackPGreen
Copy link
Collaborator Author

@nishaatr I've (substantially) updates this PR and cleared your review accordingly.

@JackPGreen JackPGreen force-pushed the simplify-`publish-rhel.sh` branch from 7688f53 to f0e4000 Compare September 4, 2025 22:39
@JackPGreen JackPGreen requested a review from nishaatr September 5, 2025 10:43
@JackPGreen JackPGreen enabled auto-merge (squash) September 5, 2025 19:55
Copy link
Contributor

@ldziedziul ldziedziul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, have you tested it?

@JackPGreen JackPGreen merged commit 942e2d2 into master Sep 11, 2025
20 checks passed
@JackPGreen JackPGreen deleted the simplify-`publish-rhel.sh` branch September 11, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants