From 8f4b1df9cf301a1f91049a2d49a8ff7c80485b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Fri, 14 Jul 2023 10:16:51 +0200 Subject: [PATCH] kata-deploy: Give users the ability to run it on DEBUG mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../kata-cleanup/base/kata-cleanup.yaml | 2 ++ .../kata-deploy/base/kata-deploy.yaml | 2 ++ .../kata-deploy/scripts/kata-deploy.sh | 34 +++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml b/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml index 095876b732..b2b4f01d01 100644 --- a/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml +++ b/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml @@ -26,6 +26,8 @@ spec: valueFrom: fieldRef: fieldPath: spec.nodeName + - name: DEBUG + value: "no" securityContext: privileged: true volumeMounts: diff --git a/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml b/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml index 97e98ee741..d072c1085e 100644 --- a/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml +++ b/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml @@ -28,6 +28,8 @@ spec: valueFrom: fieldRef: fieldPath: spec.nodeName + - name: DEBUG + value: "no" securityContext: privileged: true volumeMounts: diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 09d27cc654..d61804641c 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -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 <