cache_components: Add the ability to cache the shim-v2

In order to cache the shim-v2 we're considering the the cached component
can be used if:
* There were no changes in the runtime directory
* There were no changes in the golang version used
* There were no changes in the rust version used
  * We don't build the rust agent, but better be prepared for the future
* There were no changes in the following files that are provided by the
  rootfs builds:
  * root_hash_vanilla.txt
  * root_hash_tdx.txt

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Gabriela Cervantes
2022-12-05 16:48:13 +00:00
committed by Fabiano Fidêncio
parent d9dd1ac9ec
commit de69f9c832
2 changed files with 19 additions and 2 deletions

View File

@@ -105,6 +105,16 @@ cache_rootfs_artifacts() {
create_cache_asset "${rootfs_tarball_name}" "${current_rootfs_version}" "" "${root_hash_vanilla}" "${root_hash_tdx}" create_cache_asset "${rootfs_tarball_name}" "${current_rootfs_version}" "" "${root_hash_vanilla}" "${root_hash_tdx}"
} }
cache_shim_v2_artifacts() {
local shim_v2_tarball_name="kata-static-cc-shim-v2.tar.xz"
local shim_v2_last_commit="$(get_last_modification "${repo_root_dir}/src/runtime")"
local golang_version="$(get_from_kata_deps "languages.golang.meta.newest-version")"
local rust_version="$(get_from_kata_deps "languages.rust.meta.newest-version")"
local current_shim_v2_version="${shim_v2_last_commit}-${golang_version}-${rust_version}"
local current_shim_v2_image="$(get_shim_v2_image_name)"
create_cache_asset "${shim_v2_tarball_name}" "${current_shim_v2_version}" "${current_shim_v2_image}" "${repo_root_dir}/tools/osbuilder/root_hash_vanilla.txt" "${repo_root_dir}/tools/osbuilder/root_hash_tdx.txt"
}
create_cache_asset() { create_cache_asset() {
local component_name="${1}" local component_name="${1}"
local component_version="${2}" local component_version="${2}"
@@ -153,6 +163,7 @@ Usage: $0 "[options]"
* Requires FIRMWARE environment variable set, valid values are: * Requires FIRMWARE environment variable set, valid values are:
* tdvf * tdvf
* td-shim * td-shim
-s Shim v2 cache
-v Virtiofsd cache -v Virtiofsd cache
-r Rootfs Cache -r Rootfs Cache
* can receive a TEE environment variable value, valid values are: * can receive a TEE environment variable value, valid values are:
@@ -168,10 +179,11 @@ main() {
local qemu_component="${qemu_component:-}" local qemu_component="${qemu_component:-}"
local kernel_component="${kernel_component:-}" local kernel_component="${kernel_component:-}"
local firmware_component="${firmware_component:-}" local firmware_component="${firmware_component:-}"
local shim_v2_component="${shim_v2_component:-}"
local virtiofsd_component="${virtiofsd_component:-}" local virtiofsd_component="${virtiofsd_component:-}"
local rootfs_component="${rootfs_component:-}" local rootfs_component="${rootfs_component:-}"
local OPTIND local OPTIND
while getopts ":ckqfvrh:" opt while getopts ":ckqfvrsh:" opt
do do
case "$opt" in case "$opt" in
c) c)
@@ -186,6 +198,9 @@ main() {
f) f)
firmware_component="1" firmware_component="1"
;; ;;
s)
shim_v2_component="1"
;;
v) v)
virtiofsd_component="1" virtiofsd_component="1"
;; ;;
@@ -209,6 +224,7 @@ main() {
[[ -z "${kernel_component}" ]] && \ [[ -z "${kernel_component}" ]] && \
[[ -z "${qemu_component}" ]] && \ [[ -z "${qemu_component}" ]] && \
[[ -z "${firmware_component}" ]] && \ [[ -z "${firmware_component}" ]] && \
[[ -z "${shim_v2_component}" ]] && \
[[ -z "${virtiofsd_component}" ]] && \ [[ -z "${virtiofsd_component}" ]] && \
[[ -z "${rootfs_component}" ]] && \ [[ -z "${rootfs_component}" ]] && \
help && die "Must choose at least one option" help && die "Must choose at least one option"
@@ -221,6 +237,7 @@ main() {
[ "${kernel_component}" == "1" ] && cache_kernel_artifacts [ "${kernel_component}" == "1" ] && cache_kernel_artifacts
[ "${qemu_component}" == "1" ] && cache_qemu_artifacts [ "${qemu_component}" == "1" ] && cache_qemu_artifacts
[ "${firmware_component}" == "1" ] && cache_firmware_artifacts [ "${firmware_component}" == "1" ] && cache_firmware_artifacts
[ "${shim_v2_component}" == "1" ] && cache_shim_v2_artifacts
[ "${virtiofsd_component}" == "1" ] && cache_virtiofsd_artifacts [ "${virtiofsd_component}" == "1" ] && cache_virtiofsd_artifacts
[ "${rootfs_component}" == "1" ] && cache_rootfs_artifacts [ "${rootfs_component}" == "1" ] && cache_rootfs_artifacts

View File

@@ -49,7 +49,7 @@ if [ -n "${RUST_VERSION}" ]; then
"${container_image}" \ "${container_image}" \
bash -c "git config --global --add safe.directory ${repo_root_dir} && make PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" install" bash -c "git config --global --add safe.directory ${repo_root_dir} && make PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" install"
fi fi
sudo docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \ sudo docker run --rm -i -v "${repo_root_dir}:${repo_root_dir}" \
-w "${repo_root_dir}/src/runtime" \ -w "${repo_root_dir}/src/runtime" \
"${container_image}" \ "${container_image}" \