kata-deploy: Give users the ability to run it on DEBUG mode

The DEBUG env var introduced to the kata-deploy / kata-cleanup yaml file
will be responsible for:
* Setting up the CRI Engine to run with the debug log level set to debug
  * The default is usually info
* Setting up Kata Containers to enable:
  * debug logs
  * debug console
  * agent logs

This will help a lot folks trying to debug Kata Containers while using
kata-deploy, and also help us to always run with DEBUG=yes as part of
our CI.

Fixes: #7342

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2023-07-14 10:16:51 +02:00
parent 9b3dc572ae
commit 8f4b1df9cf
3 changed files with 38 additions and 0 deletions

View File

@ -26,6 +26,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: DEBUG
value: "no"
securityContext:
privileged: true
volumeMounts:

View File

@ -28,6 +28,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: DEBUG
value: "no"
securityContext:
privileged: true
volumeMounts:

View File

@ -10,6 +10,7 @@ set -o nounset
crio_drop_in_conf_dir="/etc/crio/crio.conf.d/"
crio_drop_in_conf_file="${crio_drop_in_conf_dir}/99-kata-deploy"
crio_drop_in_conf_file_debug="${crio_drop_in_conf_dir}/100-debug"
containerd_conf_file="/etc/containerd/config.toml"
containerd_conf_file_backup="${containerd_conf_file}.bak"
@ -65,6 +66,16 @@ function install_artifacts() {
[ -d /opt/kata/runtime-rs/bin ] && \
chmod +x /opt/kata/runtime-rs/bin/*
# Allow enabling debug for Kata Containers
if [[ "${DEBUG:-"no"}" == "yes" ]]; then
config_path="/opt/kata/share/defaults/kata-containers/"
for shim in "${shims[@]}"; do
sed -i -e 's/^#\(enable_debug\).*=.*$/\1 = true/g' "${config_path}/configuration-${shim}.toml"
sed -i -e 's/^#\(debug_console_enabled\).*=.*$/\1 = true/g' "${config_path}/configuration-${shim}.toml"
sed -i -e 's/^kernel_params = "\(.*\)"/kernel_params = "\1 agent.log=debug initcall_debug"/g' "${config_path}/configuration-${shim}.toml"
done
fi
# Allow Mariner to use custom configuration.
if [ "${HOST_OS:-}" == "cbl-mariner" ]; then
config_path="/opt/kata/share/defaults/kata-containers/configuration-clh.toml"
@ -212,6 +223,14 @@ function configure_crio() {
for shim in "${shims[@]}"; do
configure_crio_runtime $shim
done
if [ "${DEBUG:-"no"}" == "yes" ]; then
cat <<EOF | tee -a $crio_drop_in_conf_file_debug
[crio]
log_level = "debug"
EOF
fi
}
function configure_containerd_runtime() {
@ -250,6 +269,18 @@ EOF
ConfigPath = "${config_path}"
EOF
fi
if [ "${DEBUG:-"no"}" == "yes" ]; then
if grep -q "\[debug\]" $containerd_conf_file; then
sed -i 's/level.*/level = \"debug\"/' $containerd_conf_file
else
cat <<EOF | tee -a "$containerd_conf_file"
[debug]
level = "debug"
EOF
fi
fi
}
function configure_containerd() {
@ -292,6 +323,9 @@ function cleanup_cri_runtime() {
function cleanup_crio() {
rm $crio_drop_in_conf_file
if [[ "${DEBUG:-"no"}" == "yes" ]]; then
rm $crio_drop_in_conf_file_debug
fi
}
function cleanup_containerd() {