@@ -94,18 +94,21 @@ jobs:
9494 # Dynamically define job matrix.
9595 # We need a separate matrix entry for each distribution, when the relevant input is true.
9696 # https://stackoverflow.com/questions/65384420/how-do-i-make-a-github-action-matrix-element-conditional
97+ # NOTE(bbezak): Both amd64 and aarch64 need to be built in a single workflow to create a multi-architecture manifest.
98+ # For now include only RL9 in aarch64
9799 - name : Generate build matrix
98100 id : set-matrix
99101 run : |
100102 output="{'distro': ["
101103 if [[ ${{ inputs.rocky-linux-9 }} == 'true' ]]; then
102- output+="{'name': 'rocky', 'release': 9},"
104+ output+="{'name': 'rocky', 'release': 9, 'arch': 'amd64'},"
105+ output+="{'name': 'rocky', 'release': 9, 'arch': 'aarch64'},"
103106 fi
104107 if [[ ${{ inputs.ubuntu-jammy }} == 'true' ]]; then
105- output+="{'name': 'ubuntu', 'release': 'jammy'},"
108+ output+="{'name': 'ubuntu', 'release': 'jammy', 'arch': 'amd64' },"
106109 fi
107110 if [[ ${{ inputs.ubuntu-noble }} == 'true' ]]; then
108- output+="{'name': 'ubuntu', 'release': 'noble'},"
111+ output+="{'name': 'ubuntu', 'release': 'noble', 'arch': 'amd64' },"
109112 fi
110113 # remove trailing comma
111114 output="${output%,}"
@@ -124,7 +127,9 @@ jobs:
124127 container-image-build :
125128 name : Build Kolla container images
126129 if : github.repository == 'stackhpc/stackhpc-kayobe-config'
127- runs-on : ${{ needs.runner-selection.outputs.runner_name_container_image_build }}
130+ runs-on : ${{ matrix.distro.arch == 'aarch64'
131+ && fromJson('["self-hosted","sms","arm64"]')
132+ || needs.runner-selection.outputs.runner_name_container_image_build }}
128133 timeout-minutes : 720
129134 permissions : {}
130135 strategy :
@@ -162,7 +167,8 @@ jobs:
162167
163168 - name : Install yq
164169 run : |
165- curl -sL https://github.com/mikefarah/yq/releases/download/v4.42.1/yq_linux_amd64.tar.gz | tar xz && sudo mv yq_linux_amd64 /usr/bin/yq
170+ ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
171+ curl -sL "https://github.com/mikefarah/yq/releases/download/v4.42.1/yq_linux_${ARCH}.tar.gz" | tar xz && sudo mv yq_linux_${ARCH} /usr/bin/yq
166172
167173 - name : Install Kayobe
168174 run : |
@@ -204,16 +210,23 @@ jobs:
204210 KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
205211
206212 - name : Create build logs output directory
207- run : mkdir image-build-logs
213+ run : mkdir -p image-build-logs
208214
209215 - name : Build kolla overcloud images
210216 id : build_overcloud_images
211217 continue-on-error : true
212218 run : |
213219 args="${{ inputs.regexes }}"
220+ if [[ "${{ matrix.distro.arch }}" == 'aarch64' ]]; then
221+ args="$args -e kolla_base_arch=${{ matrix.distro.arch }}"
222+ fi
214223 args="$args -e kolla_base_distro=${{ matrix.distro.name }}"
215224 args="$args -e kolla_base_distro_version=${{ matrix.distro.release }}"
216- args="$args -e kolla_tag=${{ steps.write-kolla-tag.outputs.kolla-tag }}"
225+ if [[ "${{ matrix.distro.name }}" == 'rocky' ]]; then
226+ args="$args -e kolla_tag=${{ steps.write-kolla-tag.outputs.kolla-tag }}-${{ matrix.distro.arch }}"
227+ else
228+ args="$args -e kolla_tag=${{ steps.write-kolla-tag.outputs.kolla-tag }}"
229+ fi
217230 args="$args -e stackhpc_repo_mirror_auth_proxy_enabled=true"
218231 source venvs/kayobe/bin/activate &&
219232 source src/kayobe-config/kayobe-env --environment ci-builder &&
@@ -226,6 +239,10 @@ jobs:
226239 run : sudo mv /var/log/kolla-build.log image-build-logs/kolla-build-overcloud.log
227240 if : inputs.overcloud
228241
242+ - name : Copy build configs to output directory
243+ run : sudo cp -rnL /opt/kayobe/etc/kolla/* image-build-logs/
244+ if : inputs.overcloud
245+
229246 - name : Build kolla seed images
230247 id : build_seed_images
231248 continue-on-error : true
@@ -239,14 +256,14 @@ jobs:
239256 kayobe seed container image build $args
240257 env :
241258 KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
242- if : inputs.seed
259+ if : inputs.seed && matrix.distro.arch == 'amd64'
243260
244261 - name : Copy seed container image build logs to output directory
245262 run : sudo mv /var/log/kolla-build.log image-build-logs/kolla-build-seed.log
246- if : inputs.seed
263+ if : inputs.seed && matrix.distro.arch == 'amd64'
247264
248265 - name : Get built container images
249- run : docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/*:${{ steps.write-kolla-tag.outputs.kolla-tag }}" > ${{ matrix.distro.name }}-${{ matrix.distro.release }}-container-images
266+ run : docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/*:${{ steps.write-kolla-tag.outputs.kolla-tag }}* " > ${{ matrix.distro.name }}-${{ matrix.distro.release }}-container-images
250267
251268 - name : Fail if no images have been built
252269 run : if [ $(wc -l < ${{ matrix.distro.name }}-${{ matrix.distro.release }}-container-images) -le 1 ]; then exit 1; fi
@@ -307,7 +324,7 @@ jobs:
307324 - name : Upload output artifact
308325 uses : actions/upload-artifact@v4
309326 with :
310- name : ${{ matrix.distro.name }}-${{ matrix.distro.release }}-logs
327+ name : ${{ matrix.distro.name }}-${{ matrix.distro.release }}-${{ matrix.distro.arch }}- logs
311328 path : image-build-logs
312329 retention-days : 7
313330 if : ${{ !cancelled() }}
@@ -331,6 +348,117 @@ jobs:
331348 run : if [ $(wc -l < image-build-logs/image-scan-output/critical-images.txt) -gt 0 ]; then cat image-build-logs/image-scan-output/critical-images.txt && exit 1; fi
332349 if : ${{ !inputs.push-dirty && !cancelled() }}
333350
351+ create-manifests :
352+ # Only for Rocky Linux for now
353+ name : Create Multiarch Docker Manifests
354+ if : github.repository == 'stackhpc/stackhpc-kayobe-config' && inputs.push
355+ runs-on : ${{ needs.runner-selection.outputs.runner_name_container_image_build }}
356+ permissions : {}
357+ needs :
358+ - container-image-build
359+ - runner-selection
360+ steps :
361+ - name : Install package dependencies
362+ run : |
363+ sudo apt update
364+ sudo apt install -y git unzip python3-wheel python3-pip python3-venv curl jq wget openssh-server openssh-client
365+ - name : Install gh
366+ run : |
367+ sudo mkdir -p -m 755 /etc/apt/keyrings && wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
368+ sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
369+ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
370+ sudo apt update
371+ sudo apt install gh -y
372+ - name : Checkout Kayobe Config
373+ uses : actions/checkout@v4
374+ with :
375+ path : src/kayobe-config
376+
377+ - name : Install Kayobe
378+ run : |
379+ mkdir -p venvs &&
380+ pushd venvs &&
381+ python3 -m venv kayobe &&
382+ source kayobe/bin/activate &&
383+ pip install -U pip &&
384+ pip install -r ../src/kayobe-config/requirements.txt
385+ # Required for Pulp auth proxy deployment and Docker registry login.
386+ # Normally installed during host configure.
387+ - name : Install Docker Python SDK
388+ run : |
389+ sudo pip install docker
390+ - name : Configure localhost as a seed
391+ run : |
392+ cat > src/kayobe-config/etc/kayobe/environments/ci-builder/inventory/hosts << EOF
393+ # A 'seed' host used for building images.
394+ # Use localhost for container image builds.
395+ [seed]
396+ localhost ansible_connection=local ansible_python_interpreter=/usr/bin/python3
397+ EOF
398+ # See etc/kayobe/ansible/roles/pulp_auth_proxy/README.md for details.
399+ # NOTE: We override pulp_auth_proxy_conf_path to a path shared by the
400+ # runner and dind containers.
401+ - name : Deploy an authenticating package repository mirror proxy
402+ run : |
403+ source venvs/kayobe/bin/activate &&
404+ source src/kayobe-config/kayobe-env --environment ci-builder &&
405+ kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/pulp-auth-proxy.yml -e pulp_auth_proxy_conf_path=/home/runner/_work/pulp_proxy
406+ env :
407+ KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
408+
409+ - name : Download artifacts
410+ uses : actions/download-artifact@v4
411+
412+ - name : Combine pushed images lists
413+ run : |
414+ find . -name 'push-attempt-images.txt' -exec cat {} + > all-pushed-images.txt
415+ - name : Log in to Docker registry
416+ run : |
417+ source venvs/kayobe/bin/activate &&
418+ source src/kayobe-config/kayobe-env --environment ci-builder &&
419+ kayobe playbook run ${KAYOBE_CONFIG_PATH}/ansible/docker-registry-login.yml
420+ env :
421+ KAYOBE_VAULT_PASSWORD : ${{ secrets.KAYOBE_VAULT_PASSWORD }}
422+
423+ - name : Create and Push Docker Manifests
424+ run : |
425+ set -ex
426+ mkdir -p logs
427+ images=$(cat all-pushed-images.txt | sort | uniq)
428+ # Filter out Ubuntu and Rocky Bifrost images
429+ manifest_images=$(echo "$images" | grep -E '.*-(amd64|aarch64)$' | sed -E 's/-(amd64|aarch64)$//' | sort | uniq)
430+ if [ -z "$manifest_images" ]; then
431+ echo "No Rocky overcloud images found. Skipping manifest creation." | tee -a logs/manifest-creation.log
432+ exit 0
433+ fi
434+ for base_image in $manifest_images; do
435+ arch_images=""
436+ for arch in amd64 aarch64; do
437+ arch_image="${base_image}-${arch}"
438+ # Check if the image exists in the registry
439+ if docker manifest inspect "$arch_image" > /dev/null 2>&1; then
440+ arch_images="$arch_images $arch_image"
441+ fi
442+ done
443+ if [ -n "$arch_images" ]; then
444+ echo "Creating manifest for $base_image with images:$arch_images" | tee -a logs/manifest-creation.log
445+ docker manifest create "$base_image" $arch_images | tee -a logs/manifest-creation.log
446+ docker manifest push "$base_image" | tee -a logs/manifest-creation.log
447+ else
448+ echo "No images found for $base_image, skipping." | tee -a logs/manifest-creation.log
449+ fi
450+ done
451+
452+ - name : Upload manifest logs
453+ uses : actions/upload-artifact@v4
454+ with :
455+ name : manifest-logs
456+ path : |
457+ all-pushed-images.txt
458+ logs/manifest-creation.log
459+ retention-days : 7
460+ if : ${{ !cancelled() }}
461+
334462 # NOTE(mgoddard): Trigger another CI workflow in the
335463 # stackhpc-release-train repository.
336464 - name : Trigger container image repository sync
0 commit comments