Skip to content

Commit

Permalink
packaging: Don't build the agent if not needed
Browse files Browse the repository at this point in the history
Let's start relying on the already cached agent to be deployed inside
the rootfs.  By doing this we save a lot of time in our CI, and we have
a better way, for developers, to play with changes in the agent.

Fixes: #8915

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
  • Loading branch information
fidencio committed Jan 25, 2024
1 parent 21fd7e6 commit dd49479
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions tools/packaging/guest-image/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ source "${packaging_root_dir}/scripts/lib.sh"
readonly osbuilder_dir="$(cd "${repo_root_dir}/tools/osbuilder" && pwd)"

export GOPATH=${GOPATH:-${HOME}/go}
export AGENT_TARBALL=${AGENT_TARBALL:-}

ARCH=${ARCH:-$(uname -m)}
if [ $(uname -m) == "${ARCH}" ]; then
Expand All @@ -41,6 +42,7 @@ build_initrd() {
OS_VERSION="${os_version}" \
ROOTFS_BUILD_DEST="${builddir}/initrd-image" \
USE_DOCKER=1 \
AGENT_TARBALL="${AGENT_TARBALL}" \
AGENT_INIT="yes" \
AGENT_POLICY="${AGENT_POLICY:-}"
mv "kata-containers-initrd.img" "${install_dir}/${artifact_name}"
Expand All @@ -60,6 +62,7 @@ build_image() {
USE_DOCKER="1" \
IMG_OS_VERSION="${os_version}" \
ROOTFS_BUILD_DEST="${builddir}/rootfs-image" \
AGENT_TARBALL="${AGENT_TARBALL}" \
AGENT_POLICY="${AGENT_POLICY:-}"
mv -f "kata-containers.img" "${install_dir}/${artifact_name}"
if [ -e "root_hash.txt" ]; then
Expand Down
10 changes: 5 additions & 5 deletions tools/packaging/kata-deploy/local-build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,19 @@ qemu-tdx-experimental-tarball:
stratovirt-tarball:
${MAKE} $@-build

rootfs-image-tarball:
rootfs-image-tarball: agent-tarball
${MAKE} $@-build

rootfs-image-tdx-tarball: kernel-tdx-experimental-tarball
rootfs-image-tdx-tarball: agent-opa-tarball kernel-tdx-experimental-tarball
${MAKE} $@-build

rootfs-initrd-mariner-tarball:
rootfs-initrd-mariner-tarball: agent-opa-tarball
${MAKE} $@-build

rootfs-initrd-sev-tarball: kernel-sev-tarball
rootfs-initrd-sev-tarball: agent-opa-tarball kernel-sev-tarball
${MAKE} $@-build

rootfs-initrd-tarball:
rootfs-initrd-tarball: agent-tarball
${MAKE} $@-build

runk-tarball:
Expand Down
14 changes: 13 additions & 1 deletion tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ install_cached_tarball_component() {
mv "${component_tarball_name}" "${component_tarball_path}"
}

get_agent_tarball_path() {
agent_local_build_dir="${repo_root_dir}/tools/packaging/kata-deploy/local-build/build"
agent_tarball_name="kata-static-agent.tar.xz"
if [ "${AGENT_POLICY:-no}" = "yes" ]; then
agent_tarball_name="kata-static-agent-opa.tar.xz"
fi

echo "${agent_local_build_dir}/${agent_tarball_name}"
}

#Install guest image
install_image() {
local variant="${1:-}"
Expand Down Expand Up @@ -195,7 +205,8 @@ install_image() {
os_name="$(get_from_kata_deps "assets.image.architecture.${ARCH}.name")"
os_version="$(get_from_kata_deps "assets.image.architecture.${ARCH}.version")"
fi


export AGENT_TARBALL=$(get_agent_tarball_path)
"${rootfs_builder}" --osname="${os_name}" --osversion="${os_version}" --imagetype=image --prefix="${prefix}" --destdir="${destdir}" --image_initrd_suffix="${variant}"
}

Expand Down Expand Up @@ -247,6 +258,7 @@ install_initrd() {
os_version="$(get_from_kata_deps "assets.initrd.architecture.${ARCH}.version")"
fi

export AGENT_TARBALL=$(get_agent_tarball_path)
"${rootfs_builder}" --osname="${os_name}" --osversion="${os_version}" --imagetype=initrd --prefix="${prefix}" --destdir="${destdir}" --image_initrd_suffix="${variant}"
}

Expand Down

0 comments on commit dd49479

Please sign in to comment.