From 194d5dc8a6e92a56077dff8684d8b9b49a95b83b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 16 Mar 2023 13:17:19 +0100 Subject: [PATCH] tools: Add support for caching VirtioFS artefacts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let's add support for caching VirtioFS artefacts that are generated using the kata-deploy local-build scripts. Right now those are not used, but we'll switch to using them very soon as part of upcoming changes of how we build the components we test in our CI. Fixes: #6480 Signed-off-by: Fabiano FidĂȘncio Signed-off-by: Gabriela Cervantes --- tools/packaging/scripts/lib.sh | 21 +++++++++++++++++++ .../static-build/cache_components_main.sh | 16 +++++++++++++- .../packaging/static-build/virtiofsd/build.sh | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/tools/packaging/scripts/lib.sh b/tools/packaging/scripts/lib.sh index 61776bcbff..c425341081 100644 --- a/tools/packaging/scripts/lib.sh +++ b/tools/packaging/scripts/lib.sh @@ -180,3 +180,24 @@ get_shim_v2_image_name() { shim_v2_script_dir="${repo_root_dir}/tools/packaging/static-build/shim-v2" echo "${BUILDER_REGISTRY}:shim-v2-go-$(get_from_kata_deps "languages.golang.meta.newest-version")-rust-$(get_from_kata_deps "languages.rust.meta.newest-version")-$(get_last_modification ${shim_v2_script_dir})-$(uname -m)" } + +get_virtiofsd_image_name() { + ARCH=$(uname -m) + case ${ARCH} in + "aarch64") + libc="musl" + ;; + "ppc64le") + libc="gnu" + ;; + "s390x") + libc="gnu" + ;; + "x86_64") + libc="musl" + ;; + esac + + virtiofsd_script_dir="${repo_root_dir}/tools/packaging/static-build/virtiofsd" + echo "${BUILDER_REGISTRY}:virtiofsd-$(get_from_kata_deps "externals.virtiofsd.toolchain")-${libc}-$(get_last_modification ${virtiofsd_script_dir})-$(uname -m)" +} diff --git a/tools/packaging/static-build/cache_components_main.sh b/tools/packaging/static-build/cache_components_main.sh index ef9cf6b9c9..e447ab4bfa 100755 --- a/tools/packaging/static-build/cache_components_main.sh +++ b/tools/packaging/static-build/cache_components_main.sh @@ -74,6 +74,13 @@ cache_shim_v2_artifacts() { create_cache_asset "${shim_v2_tarball_name}" "${current_shim_v2_version}" "${current_shim_v2_image}" } +cache_virtiofsd_artifacts() { + local virtiofsd_tarball_name="kata-static-virtiofsd.tar.xz" + local current_virtiofsd_version="$(get_from_kata_deps "externals.virtiofsd.version")-$(get_from_kata_deps "externals.virtiofsd.toolchain")" + local current_virtiofsd_image="$(get_virtiofsd_image_name)" + create_cache_asset "${virtiofsd_tarball_name}" "${current_virtiofsd_version}" "${current_virtiofsd_image}" +} + create_cache_asset() { local component_name="${1}" local component_version="${2}" @@ -106,6 +113,7 @@ Usage: $0 "[options]" * Export ROOTFS_IMAGE_TYPE="image|initrd" for one of those two types The default ROOTFS_IMAGE_TYPE value is "image" -s Shim v2 cache + -v VirtioFS cache -h Shows help EOF )" @@ -119,8 +127,9 @@ main() { local qemu_component="${qemu_component:-}" local rootfs_component="${rootfs_component:-}" local shim_v2_component="${shim_v2_component:-}" + local virtiofsd_component="${virtiofsd_component:-}" local OPTIND - while getopts ":cFknqrsh:" opt + while getopts ":cFknqrsvh:" opt do case "$opt" in c) @@ -144,6 +153,9 @@ main() { s) shim_v2_component="1" ;; + v) + virtiofsd_component="1" + ;; h) help exit 0; @@ -164,6 +176,7 @@ main() { [[ -z "${qemu_component}" ]] && \ [[ -z "${rootfs_component}" ]] && \ [[ -z "${shim_v2_component}" ]] && \ + [[ -z "${virtiofsd_component}" ]] && \ help && die "Must choose at least one option" mkdir -p "${WORKSPACE}/artifacts" @@ -177,6 +190,7 @@ main() { [ "${qemu_component}" == "1" ] && cache_qemu_artifacts [ "${rootfs_component}" == "1" ] && cache_rootfs_artifacts [ "${shim_v2_component}" == "1" ] && cache_shim_v2_artifacts + [ "${virtiofsd_component}" == "1" ] && cache_virtiofsd_artifacts ls -la "${WORKSPACE}/artifacts/" popd diff --git a/tools/packaging/static-build/virtiofsd/build.sh b/tools/packaging/static-build/virtiofsd/build.sh index 68b3358210..6eb5ad51bf 100755 --- a/tools/packaging/static-build/virtiofsd/build.sh +++ b/tools/packaging/static-build/virtiofsd/build.sh @@ -48,7 +48,7 @@ case ${ARCH} in ;; esac -container_image="${VIRTIOFSD_CONTAINER_BUILDER:-${BUILDER_REGISTRY}:virtiofsd-${virtiofsd_toolchain}-${libc}-$(get_last_modification ${script_dir})-$(uname -m)}" +container_image="${VIRTIOFSD_CONTAINER_BUILDER:-$(get_virtiofsd_image_name)}" sudo docker pull ${container_image} || \ (sudo docker build \