mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-01 09:42:45 +00:00
rootfs.sh: trap build errors for specific distros
Add the ability to trap a build error inside rootfs.sh, without returning an error code. Gating conditions (all of them are needed): - GRACEFUL_EXIT shall be passed as env variable to rootfs.sh - BUILD_CAN_FAIL shall be specified in the distro config.sh Signed-off-by: Marco Vedovati <mvedovati@suse.com>
This commit is contained in:
parent
c8ae9c077c
commit
57d0a8300b
@ -77,6 +77,13 @@ AGENT_VERSION Version of the agent to include in the rootfs.
|
||||
GO_AGENT_PKG URL of the Git repository hosting the agent package.
|
||||
Default value: ${GO_AGENT_PKG}
|
||||
|
||||
GRACEFUL_EXIT If set, and if the <distro> configuration specifies a
|
||||
non-empty BUILD_CAN_FAIL variable, do not return with an
|
||||
error code in case any of the build step fails.
|
||||
This is used when running CI jobs, to tolerate failures for
|
||||
specific distributions.
|
||||
Default value: <not set>
|
||||
|
||||
KERNEL_MODULES_DIR Path to a directory containing kernel modules to include in
|
||||
the rootfs.
|
||||
Default value: <empty>
|
||||
@ -88,7 +95,6 @@ USE_DOCKER If set, build the rootfs inside a container (requires
|
||||
Docker).
|
||||
Default value: <not set>
|
||||
|
||||
|
||||
Refer to the Platform-OS Compatibility Matrix for more details on the supported
|
||||
architectures:
|
||||
https://github.com/kata-containers/osbuilder#platform-distro-compatibility-matrix
|
||||
@ -213,6 +219,16 @@ copy_kernel_modules()
|
||||
OK "Kernel modules copied"
|
||||
}
|
||||
|
||||
error_handler()
|
||||
{
|
||||
[ "$?" -eq 0 ] && return
|
||||
|
||||
if [ -n "$GRACEFUL_EXIT" ] && [ -n "$BUILD_CAN_FAIL" ]; then
|
||||
info "Detected a build error, but $distro is allowed to fail (BUILD_CAN_FAIL specified), so exiting sucessfully"
|
||||
touch "$(dirname ${ROOTFS_DIR})/${distro}_fail"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
while getopts a:hlo:r:t: opt
|
||||
do
|
||||
@ -271,6 +287,11 @@ fi
|
||||
CONFIG_DIR=${distro_config_dir}
|
||||
check_function_exist "build_rootfs"
|
||||
|
||||
if [ -z "$INSIDE_CONTAINER" ] ; then
|
||||
# Capture errors, but only outside of the docker container
|
||||
trap error_handler ERR
|
||||
fi
|
||||
|
||||
if [ -n "${USE_DOCKER}" ] ; then
|
||||
image_name="${distro}-rootfs-osbuilder"
|
||||
|
||||
@ -304,6 +325,7 @@ if [ -n "${USE_DOCKER}" ] ; then
|
||||
--env KERNEL_MODULES_DIR="${KERNEL_MODULES_DIR}" \
|
||||
--env EXTRA_PKGS="${EXTRA_PKGS}" \
|
||||
--env OSBUILDER_VERSION="${OSBUILDER_VERSION}" \
|
||||
--env INSIDE_CONTAINER=1 \
|
||||
-v "${script_dir}":"/osbuilder" \
|
||||
-v "${ROOTFS_DIR}":"/rootfs" \
|
||||
-v "${script_dir}/../scripts":"/scripts" \
|
||||
|
@ -17,3 +17,6 @@ INIT_PROCESS=systemd
|
||||
# List of zero or more architectures to exclude from build,
|
||||
# as reported by `uname -m`
|
||||
ARCH_EXCLUDE_LIST=()
|
||||
# [When uncommented,] Allow the build to fail without generating an error
|
||||
# For more info see: https://github.com/kata-containers/osbuilder/issues/190
|
||||
#BUILD_CAN_FAIL=1
|
||||
|
Loading…
Reference in New Issue
Block a user