kata-deploy: Use rust runtime config files in runtime-rs directory

Update `kata-deploy` to modify the rust runtime configuration files in
their new `runtime-rs/` directory.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2023-11-14 17:15:59 +00:00 committed by Fabiano Fidêncio
parent 80860478bf
commit fc28deee0e

View File

@ -105,6 +105,42 @@ function get_container_runtime() {
fi
}
function get_kata_containers_config_path() {
local shim="$1"
# Directory holding pristine configuration files for the current default golang runtime.
local golang_config_path="/opt/kata/share/defaults/kata-containers/"
# Directory holding pristine configuration files for the new rust runtime.
#
# These are put into a separate directory since:
#
# - In some cases, the rust runtime configuration syntax is
# slightly different to the golang runtime configuration files
# so some hypervisors need two different configuration files,
# one for reach runtime type (for example Cloud Hypervisor which
# uses 'clh' for the golang runtime and 'cloud-hypervisor' for
# the rust runtime.
#
# - Some hypervisors only currently work with the golang runtime.
#
# - Some hypervisors only work with the rust runtime (dragonball).
#
# See: https://github.com/kata-containers/kata-containers/issues/6020
local rust_config_path="${golang_config_path}/runtime-rs"
local config_path
# Map the runtime shim name to the appropriate configuration
# file directory.
case "$shim" in
dragonball) config_path="$rust_config_path" ;;
*) config_path="$golang_config_path" ;;
esac
echo "$config_path"
}
function install_artifacts() {
echo "copying kata artifacts onto host"
cp -au /opt/kata-artifacts/opt/kata/* /opt/kata/
@ -112,8 +148,12 @@ function install_artifacts() {
[ -d /opt/kata/runtime-rs/bin ] && \
chmod +x /opt/kata/runtime-rs/bin/*
config_path="/opt/kata/share/defaults/kata-containers/"
local config_path
for shim in "${shims[@]}"; do
config_path=$(get_kata_containers_config_path "${shim}")
mkdir -p "$config_path"
local kata_config_file="${config_path}/configuration-${shim}.toml"
# Allow enabling debug for Kata Containers
if [[ "${DEBUG}" == "true" ]]; then
@ -257,9 +297,11 @@ function configure_crio_runtime() {
configuration+="-$1"
fi
local config_path=$(get_kata_containers_config_path "${1}")
local kata_path="/usr/local/bin/containerd-shim-${runtime}-v2"
local kata_conf="crio.runtime.runtimes.${runtime}"
local kata_config_path="/opt/kata/share/defaults/kata-containers/$configuration.toml"
local kata_config_path="${config_path}/${configuration}.toml"
cat <<EOF | tee -a "$crio_drop_in_conf_file"
@ -314,7 +356,7 @@ function configure_containerd_runtime() {
local runtime_table="plugins.${pluginid}.containerd.runtimes.$runtime"
local runtime_type="io.containerd.$runtime.v2"
local options_table="$runtime_table.options"
local config_path="/opt/kata/share/defaults/kata-containers/$configuration.toml"
local config_path="$(get_kata_containers_config_path "$2")/$configuration.toml"
if grep -q "\[$runtime_table\]" $containerd_conf_file; then
echo "Configuration exists for $runtime_table, overwriting"
sed -i "/\[$runtime_table\]/,+1s#runtime_type.*#runtime_type = \"${runtime_type}\"#" $containerd_conf_file