Skip to content

Commit

Permalink
kata-deploy: Give users the ability to run it on DEBUG mode
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
fidencio committed Jul 14, 2023
1 parent 9b3dc57 commit 8f4b1df
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
Expand Up @@ -26,6 +26,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: DEBUG
value: "no"
securityContext:
privileged: true
volumeMounts:
Expand Down
2 changes: 2 additions & 0 deletions tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml
Expand Up @@ -28,6 +28,8 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: DEBUG
value: "no"
securityContext:
privileged: true
volumeMounts:
Expand Down
34 changes: 34 additions & 0 deletions tools/packaging/kata-deploy/scripts/kata-deploy.sh
Expand Up @@ -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"

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 8f4b1df

Please sign in to comment.