From 1276b369af1ee2b1d129e41cda4d7e7da70e67d4 Mon Sep 17 00:00:00 2001 From: Adam Cmiel Date: Wed, 8 Jan 2025 10:40:03 +0100 Subject: [PATCH 1/3] create-repos: fix repository names The script wasn't adding the "task-" or "pipeline-" prefix to repositories Signed-off-by: Adam Cmiel --- .../scripts/create-task-pipeline-bundle-repos.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.tekton/scripts/create-task-pipeline-bundle-repos.sh b/.tekton/scripts/create-task-pipeline-bundle-repos.sh index 7242a7cd74..9894d89db4 100755 --- a/.tekton/scripts/create-task-pipeline-bundle-repos.sh +++ b/.tekton/scripts/create-task-pipeline-bundle-repos.sh @@ -26,23 +26,23 @@ locate_in_all_namespaces() { for quay_namespace in "${CATALOG_NAMESPACES[@]}"; do found=$(locate_bundle_repo "$quay_namespace" "$type" "$object") + quay_repo=${type}-${object} + # konflux-ci/tekton-catalog if [[ $quay_namespace = */* ]]; then - # tekton-catalog/ - quay_repo_prefix="${quay_namespace#*/}/" + # tekton-catalog/... + quay_repo="${quay_namespace#*/}/$quay_repo" # konflux-ci quay_namespace=${quay_namespace%%/*} - else - quay_repo_prefix="" fi - echo "Checking ${quay_namespace}/${quay_repo_prefix}${object}, http code: ${found}" + echo "Checking ${quay_namespace}/${quay_repo}, http code: ${found}" if [ "$found" != "200" ]; then - echo "Missing $type bundle repo: ${quay_repo_prefix}${object} in ${quay_namespace}, creating..." + echo "Missing $type bundle repo: ${quay_repo} in ${quay_namespace}, creating..." payload=$( jq -n \ --arg namespace "$quay_namespace" \ - --arg repository "$quay_repo_prefix$object" \ + --arg repository "$quay_repo" \ --arg visibility "public" \ --arg description "" \ '$ARGS.named' From ce7d35f04090901481bf5985594fa2d9300fc781 Mon Sep 17 00:00:00 2001 From: Adam Cmiel Date: Wed, 8 Jan 2025 16:56:08 +0100 Subject: [PATCH 2/3] create-repos: ignore "Repository already exists" Inexplicably, for some task repos, quay.io returns 401 in response to the initial request but then returns "Repository already exists" when we try to create the repo. Ignore these errors. Example: Checking konflux-ci/tekton-catalog/task-fips-operator-bundle-check, http code: 401 Missing task bundle repo: tekton-catalog/task-fips-operator-bundle-check in konflux-ci, creating... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 362 100 218 100 144 323 213 --:--:-- --:--:-- --:--:-- 537 WARNING: repository creation failed, but the error message was 'Repository already exists'. Assuming that's fine. Signed-off-by: Adam Cmiel --- .tekton/scripts/create-task-pipeline-bundle-repos.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.tekton/scripts/create-task-pipeline-bundle-repos.sh b/.tekton/scripts/create-task-pipeline-bundle-repos.sh index 9894d89db4..bef2269791 100755 --- a/.tekton/scripts/create-task-pipeline-bundle-repos.sh +++ b/.tekton/scripts/create-task-pipeline-bundle-repos.sh @@ -47,13 +47,15 @@ locate_in_all_namespaces() { --arg description "" \ '$ARGS.named' ) - if ! err_msg=$(curl --oauth2-bearer "${QUAY_TOKEN}" "https://quay.io/api/v1/repository" --data-binary "$payload" -H "Content-Type: application/json" -H "Accept: application/json" | jq '.error_message // empty'); + if ! err_msg=$(curl --oauth2-bearer "${QUAY_TOKEN}" "https://quay.io/api/v1/repository" --data-binary "$payload" -H "Content-Type: application/json" -H "Accept: application/json" | jq -r '.error_message // empty'); then echo "curl returned an error when creating the repository. See the error above." exit 1 fi - if [ -n "$err_msg" ]; then + if [[ "$err_msg" == "Repository already exists" ]]; then + echo "WARNING: repository creation failed, but the error message was '$err_msg'. Assuming that's fine." + elif [[ -n "$err_msg" ]]; then echo "Quay returned an error when creating the repository: ${err_msg}" exit 1 fi From c8565c514dbfa5a477e5c13d14e5b38112ea29fb Mon Sep 17 00:00:00 2001 From: Adam Cmiel Date: Thu, 9 Jan 2025 10:52:11 +0100 Subject: [PATCH 3/3] push CI: build bundles after creating repos The create-repositories-if-missing creates the quay repositories for the build-bundles task. Run them in the correct order. Signed-off-by: Adam Cmiel --- .tekton/push.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.tekton/push.yaml b/.tekton/push.yaml index 5c70e22641..ae345eb4b3 100644 --- a/.tekton/push.yaml +++ b/.tekton/push.yaml @@ -94,6 +94,7 @@ spec: runAfter: - build-appstudio-utils - ec-task-checks + - create-repositories-if-missing workspaces: - name: source workspace: workspace