diff --git a/.github/workflows/sub_airgap.yaml b/.github/workflows/sub_airgap.yaml index d9b1d04d1..5b8fdbf8c 100644 --- a/.github/workflows/sub_airgap.yaml +++ b/.github/workflows/sub_airgap.yaml @@ -79,14 +79,17 @@ jobs: uses: actions/checkout@v4 - name: Authenticate to GCP + id: authenticate uses: google-github-actions/auth@v2 with: credentials_json: ${{ secrets.credentials }} - name: Setup gcloud + id: setup_gcloud uses: google-github-actions/setup-gcloud@v2 - name: Download QCOW2 VM image + id: download_qcow2 run: | QCOW2_FILE=rancher-image.qcow2 gcloud storage cp gs://elemental-airgap-image/${QCOW2_FILE} ${HOME}/${QCOW2_FILE} diff --git a/tests/scripts/build-airgap b/tests/scripts/build-airgap index f39ffdde8..aef9db5d2 100755 --- a/tests/scripts/build-airgap +++ b/tests/scripts/build-airgap @@ -24,7 +24,7 @@ function RunSkopeoCmdWithRetry() { # Wait for a maximum of 1 minute for ((i=0; i<60; i++)); do # If skopeo command is OK then we simply return (exit the function) - skopeo $* && return + skopeo $* > /dev/null && return # Wait a little sleep 5 @@ -66,7 +66,7 @@ K8S_DOWNSTREAM_VERSION=${TMP_VER/v} mkdir -p ${OPT_RANCHER}/{k3s_${K8S_UPSTREAM_VERSION},k3s_${K8S_DOWNSTREAM_VERSION},helm} ${OPT_RANCHER}/images/{cert,rancher,registry,elemental} # Install packages -sudo zypper --no-refresh -n in skopeo yq +# sudo zypper --no-refresh -n in skopeo yq # Add rancher manager in /etc/hosts sudo sh -c 'echo "192.168.122.102 rancher-manager.test" >> /etc/hosts' @@ -114,38 +114,40 @@ bash ${ELEMENTAL_AIRGAP_SCRIPT} -d -r localhost:5000 -sa ${ELEMENTAL_VERSION} cd ${OPT_RANCHER}/images/ # Rancher image list -IMAGES_FILE_TMP=/tmp/rancher-images -IMAGES_FILE_UNSORTED=/tmp/rancher-images_unsorted +# IMAGES_FILE_TMP=/tmp/rancher-images +# IMAGES_FILE_UNSORTED=/tmp/rancher-images_unsorted RANCHER_IMAGES_FILE=rancher/rancher-images.txt -curl -sL https://github.com/rancher/rancher/releases/download/v${RANCHER_MANAGER_VERSION%.*}/rancher-images.txt -o ${IMAGES_FILE_TMP} +# curl -sL https://github.com/rancher/rancher/releases/download/v${RANCHER_MANAGER_VERSION%.*}/rancher-images.txt -o ${IMAGES_FILE_TMP} +curl -sL https://github.com/rancher/rancher/releases/download/v${RANCHER_MANAGER_VERSION%.*}/rancher-images.txt -o ${RANCHER_IMAGES_FILE} # Shorten rancher list with a sort # Fix library tags -sed -i -e '0,/busybox/s/busybox/library\/busybox/' -e 's/registry/library\/registry/g' ${IMAGES_FILE_TMP} - -# We need to keep the following images -IMAGES_LIST="mirrored-cluster-api-controller mirrored-pause mirrored-coredns-coredns mirrored-library-traefik" -for i in ${IMAGES_LIST}; do - IMAGES+="$(grep $i ${IMAGES_FILE_TMP})\n" -done - -# Remove things that are not needed and overlapped -sed -i -E '/neuvector|minio|gke|aks|eks|sriov|harvester|mirrored|longhorn|thanos|tekton|istio|multus|hyper|jenkins|windows/d' ${IMAGES_FILE_TMP} -echo -e ${IMAGES} >> ${IMAGES_FILE_TMP} - -# Get latest version -for i in $(awk -F: '{print $1}' ${IMAGES_FILE_TMP}); do - grep -w $i ${IMAGES_FILE_TMP} | sort -Vr | head -1 >> ${IMAGES_FILE_UNSORTED} -done - -# Except for rancher/kubectl -grep 'rancher/kubectl' ${IMAGES_FILE_TMP} >> ${IMAGES_FILE_UNSORTED} -for k8s_ver in ${K8S_UPSTREAM_VERSION} ${K8S_DOWNSTREAM_VERSION}; do - grep "rancher/system-agent-installer-k3s:v${k8s_ver}" ${IMAGES_FILE_TMP} >> ${IMAGES_FILE_UNSORTED} -done - -# Final sort -sort -u ${IMAGES_FILE_UNSORTED} > ${RANCHER_IMAGES_FILE} +# sed -i -e '0,/busybox/s/busybox/library\/busybox/' -e 's/registry/library\/registry/g' ${IMAGES_FILE_TMP} +# sed -i -e '0,/busybox/s/busybox/library\/busybox/' -e 's/registry/library\/registry/g' ${RANCHER_IMAGES_FILE} + +# # We need to keep the following images +# IMAGES_LIST="mirrored-cluster-api-controller mirrored-pause mirrored-coredns-coredns mirrored-library-traefik" +# for i in ${IMAGES_LIST}; do +# IMAGES+="$(grep $i ${IMAGES_FILE_TMP})\n" +# done +# +# # Remove things that are not needed and overlapped +# sed -i -E '/neuvector|minio|gke|aks|eks|sriov|harvester|mirrored|longhorn|thanos|tekton|istio|multus|hyper|jenkins|windows/d' ${IMAGES_FILE_TMP} +# echo -e ${IMAGES} >> ${IMAGES_FILE_TMP} +# +# # Get latest version +# for i in $(awk -F: '{print $1}' ${IMAGES_FILE_TMP}); do +# grep -w ${i} ${IMAGES_FILE_TMP} | sort -Vr | head -1 >> ${IMAGES_FILE_UNSORTED} +# done +# +# # Except for rancher/kubectl +# grep 'rancher/kubectl' ${IMAGES_FILE_TMP} >> ${IMAGES_FILE_UNSORTED} +# for k8s_ver in ${K8S_UPSTREAM_VERSION} ${K8S_DOWNSTREAM_VERSION}; do +# grep "rancher/system-agent-installer-k3s:v${k8s_ver}" ${IMAGES_FILE_TMP} >> ${IMAGES_FILE_UNSORTED} +# done +# +# # Final sort +# sort -u ${IMAGES_FILE_UNSORTED} > ${RANCHER_IMAGES_FILE} # Cert-manager image list CERT_IMAGES_FILE=cert/cert-manager-images.txt @@ -169,7 +171,7 @@ grep 'registry.opensuse.*sle-micro-iso' ${OPT_RANCHER}/helm/elemental-images.txt # Skopeo - cert-manager for i in $(< ${CERT_IMAGES_FILE}); do VAR=$(awk -F/ '{print $3}' <<< ${i}) - RunSkopeoCmdWithRetry copy docker://${i} docker-archive:cert/${VAR//:/_}.tar:${VAR} > /dev/null 2>&1 + RunSkopeoCmdWithRetry copy docker://${i} docker-archive:cert/${VAR//:/_}.tar:${VAR} & done # Skopeo - Elemental @@ -179,18 +181,32 @@ for i in $(< ${ELEMENTAL_IMAGES_FILE}); do || VALUE=\$8 VAR=$(awk -F/ "{print ${VALUE}}" <<< ${i}) - RunSkopeoCmdWithRetry copy docker://${i} docker-archive:elemental/${VAR//:/_}.tar:${VAR} > /dev/null 2>&1 + RunSkopeoCmdWithRetry copy docker://${i} docker-archive:elemental/${VAR//:/_}.tar:${VAR} & done # Skopeo - Rancher +loop=0 for i in $(< ${RANCHER_IMAGES_FILE}); do VAR=$(awk -F/ '{print $2}' <<< ${i}) - RunSkopeoCmdWithRetry copy docker://${i} docker-archive:rancher/${VAR//:/_}.tar:${VAR} > /dev/null 2>&1 + RunSkopeoCmdWithRetry copy docker://${i} docker-archive:rancher/${VAR//:/_}.tar:${VAR} & + + # Wait for skopeo jobs to finish if we already have too much jobs in parallel + # This is to avoid the "too many requests to registry" error! + if (( ++loop > 50 )); then + echo "Wait for sync..." + wait + + # Reset loop counter + loop=0 + fi done +# Wait for *ALL* skopeo jobs to finish +wait + # Skopeo - Registry -RunSkopeoCmdWithRetry copy --additional-tag registry:latest docker://registry:latest docker-archive:registry/registry.tar > /dev/null 2>&1 +RunSkopeoCmdWithRetry copy --additional-tag registry:latest docker://registry:latest docker-archive:registry/registry.tar # Compress all the things cd ${OPT_RANCHER} -tar -I zstd -vcf ${OPT_RANCHER%/*}/airgap_rancher.zst $(ls 2>/dev/null) > /dev/null 2>&1 +tar -I pzstd -vcf ${OPT_RANCHER%/*}/airgap_rancher.zst $(ls 2>/dev/null)