Skip to content

Commit

Permalink
The check for image is now more robust (apache#13556)
Browse files Browse the repository at this point in the history
The request to get manifest of the image in GitHub Packages
might randomly return either schma 1 response:

{
     "schemaVersion": 1,
     "name": "apache/airflow/master-python3.6-ci",
     "tag": "470317521",
     "architecture": "amd64",
     "fsLayers": [
        {

Or schema 2 response:

{
     "schemaVersion": 2,
     "mediaType": "application/vnd.docker.distribution.manifest.v2+json",
     "config": {
        "mediaType": "application/vnd.docker.container.image.v1+json",
        "size": 56952,
        "digest": "sha256:5c80e2ab289647802affafc5c1efc879fe4f5b559cb7a2a1215868e84b1d6424"
     },

In order to check image more reliably we check the status code
of the curl response instead.
  • Loading branch information
potiuk authored Jan 8, 2021
1 parent ad64dfa commit dc7d0a6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
2 changes: 0 additions & 2 deletions scripts/ci/images/ci_wait_for_ci_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

push_pull_remove_images::check_if_github_registry_wait_for_image_enabled

push_pull_remove_images::check_if_jq_installed

build_image::login_to_github_registry_if_needed

export AIRFLOW_CI_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}-ci"
Expand Down
2 changes: 0 additions & 2 deletions scripts/ci/images/ci_wait_for_prod_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

push_pull_remove_images::check_if_github_registry_wait_for_image_enabled

push_pull_remove_images::check_if_jq_installed

build_image::login_to_github_registry_if_needed

export AIRFLOW_PROD_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}"
Expand Down
24 changes: 5 additions & 19 deletions scripts/ci/libraries/_push_pull_remove_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -279,21 +279,19 @@ function push_pull_remove_images::wait_for_github_registry_image() {

GITHUB_API_CALL="${github_api_endpoint}/${image_name_in_github_registry}/manifests/${image_tag_in_github_registry}"
while true; do
curl --connect-timeout 60 --max-time 60 \
-X GET "${GITHUB_API_CALL}" -u "${GITHUB_USERNAME}:${GITHUB_TOKEN}" 2>/dev/null > "${OUTPUT_LOG}"
local digest
digest=$(jq '.config.digest' < "${OUTPUT_LOG}")
if [[ ${digest} != "null" ]]; then
http_status=$(curl --silent --output "${OUTPUT_LOG}" --write-out "%{http_code}" \
--connect-timeout 60 --max-time 60 \
-X GET "${GITHUB_API_CALL}" -u "${GITHUB_USERNAME}:${GITHUB_TOKEN}")
if [[ ${http_status} == "200" ]]; then
echo "${COLOR_GREEN_OK} ${COLOR_RESET}"
break
else
echo "${COLOR_YELLOW}Still waiting!${COLOR_RESET}"
echo "${COLOR_YELLOW}Still waiting - status code ${http_status}!${COLOR_RESET}"
cat "${OUTPUT_LOG}"
fi
sleep 60
done
verbosity::print_info "Found ${image_name_in_github_registry}:${image_tag_in_github_registry} image"
verbosity::print_info "Digest: '${digest}'"
}

function push_pull_remove_images::check_if_github_registry_wait_for_image_enabled() {
Expand All @@ -308,15 +306,3 @@ function push_pull_remove_images::check_if_github_registry_wait_for_image_enable
exit 1
fi
}

function push_pull_remove_images::check_if_jq_installed() {
start_end::group_start "JQ check"
echo
echo "Check if jq is installed"
echo
command -v jq >/dev/null || (echo "ERROR! You must have 'jq' tool installed!" && exit 1)
echo
echo "The jq version $(jq --version)"
echo
start_end::group_end
}

0 comments on commit dc7d0a6

Please sign in to comment.