From d46b6a3879aeb1ac06798b5ffbc6c85e858edeae Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 21 May 2024 11:24:51 +0100 Subject: [PATCH 1/3] ci: cache: Add arch suffix to all cache tags As we have multi-arch builds for nearly all components, we want to ensure that all the cache tags we set have the architecture suffix, not just the `TARGET_BRANCH` one. Signed-off-by: stevenhorsman --- .../packaging/kata-deploy/local-build/kata-deploy-binaries.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh index fe3279690c..39c305fee1 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh @@ -1137,7 +1137,7 @@ handle_build() { echo "${ARTEFACT_REGISTRY_PASSWORD}" | sudo oras login "${ARTEFACT_REGISTRY}" -u "${ARTEFACT_REGISTRY_USERNAME}" --password-stdin - tags=(latest-${TARGET_BRANCH}-$(uname -m)) + tags=(latest-"${TARGET_BRANCH}") if [ -n "${artefact_tag:-}" ]; then tags+=("${artefact_tag}") fi @@ -1150,7 +1150,7 @@ handle_build() { for tag in "${tags[@]}"; do # tags can only contain lowercase and uppercase letters, digits, underscores, periods, and hyphens, so # filter out non-printable characers and then replace invalid printable characters with underscode - tag=("$(echo ${tag} | tr -dc '[:print:]' | tr -c '[a-zA-Z0-9\_\.\-]' _)") + tag=("$(echo ${tag} | tr -dc '[:print:]' | tr -c '[a-zA-Z0-9\_\.\-]' _)-$(uname -m)") case ${build_target} in kernel-nvidia-gpu) sudo oras push \ From d6afd77eae02691f07fb94a6fb6889914a619098 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 21 May 2024 16:51:16 +0100 Subject: [PATCH 2/3] ci: cache: Update agent cache to use the full commit hash - Previously I copied the logic that abbreviated the commit hash from the versioning, but looking at our versions.yaml the clear pattern is that when pointing at commits of dependencies we use the full commit hash, not the abbreviated one, so for consistency I think we should do the same with the components that we make available Signed-off-by: stevenhorsman --- tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh index 39c305fee1..28c2213bfb 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh @@ -801,7 +801,7 @@ install_ovmf_sev() { install_agent() { latest_artefact="$(git log -1 --abbrev=9 --pretty=format:"%h" ${repo_root_dir}/src/agent)" - artefact_tag="$(git log -1 --abbrev=9 --pretty=format:"%h" ${repo_root_dir})" + artefact_tag="$(git log -1 --pretty=format:"%H" ${repo_root_dir})" latest_builder_image="$(get_agent_image_name)" install_cached_tarball_component \ From db4818fe1d3d4dc05a6c706fc545cae5ad117dd8 Mon Sep 17 00:00:00 2001 From: stevenhorsman Date: Tue, 21 May 2024 18:03:45 +0100 Subject: [PATCH 3/3] ci: cache: Enforce tag length limit Container tags can be a maximum of 128 characters long so calculate the length of the arch suffix and then restrict the tag to this length subtracted from 128 Signed-off-by: stevenhorsman --- .../kata-deploy/local-build/kata-deploy-binaries.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh index 28c2213bfb..bb121542a2 100755 --- a/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh +++ b/tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh @@ -1148,9 +1148,11 @@ handle_build() { echo "Pushing ${build_target} with tags: ${tags[*]}" for tag in "${tags[@]}"; do - # tags can only contain lowercase and uppercase letters, digits, underscores, periods, and hyphens, so - # filter out non-printable characers and then replace invalid printable characters with underscode - tag=("$(echo ${tag} | tr -dc '[:print:]' | tr -c '[a-zA-Z0-9\_\.\-]' _)-$(uname -m)") + # tags can only contain lowercase and uppercase letters, digits, underscores, periods, and hyphens + # and limited to 128 characters, so filter out non-printable characers, replace invalid printable + # characters with underscode and trim down to leave enough space for the arch suffix + tag_length_limit=$(expr 128 - $(echo "-$(uname -m)" | wc -c)) + tag=("$(echo ${tag} | tr -dc '[:print:]' | tr -c '[a-zA-Z0-9\_\.\-]' _ | head -c ${tag_length_limit})-$(uname -m)") case ${build_target} in kernel-nvidia-gpu) sudo oras push \