From 89ef464b7cd6add58dde1d6be8e14289f4c8e4dc Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 14 Nov 2023 17:13:03 +0000 Subject: [PATCH 01/11] build: Install rust config files to runtime-rs directory Install the rust runtime configuration files to a `runtime-rs/` directory to distinguish them from the golang config files (which may have a different syntax). The default values mean that the rust config files are now installed to `/opt/kata/share/defaults/kata-containers/runtime-rs/` rather than `/opt/kata/share/defaults/kata-containers/`. See: https://github.com/kata-containers/kata-containers/issues/6020 Fixes: #8444. Signed-off-by: James O. D. Hunt --- src/runtime-rs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime-rs/Makefile b/src/runtime-rs/Makefile index f492d1d334..ddf857a54b 100644 --- a/src/runtime-rs/Makefile +++ b/src/runtime-rs/Makefile @@ -189,7 +189,7 @@ KNOWN_HYPERVISORS = # List of hypervisors known for the current architecture KNOWN_HYPERVISORS = -CONFDIR := $(DEFAULTSDIR)/$(PROJECT_DIR) +CONFDIR := $(DEFAULTSDIR)/$(PROJECT_DIR)/runtime-rs SYSCONFDIR := $(SYSCONFDIR)/$(PROJECT_DIR) ##VAR CONFIG_PATH= Main configuration file location for stateless systems CONFIG_PATH := $(abspath $(CONFDIR)/$(CONFIG_FILE)) From b86ab5aa2105f6a12aea5276bffa27137711db2b Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 14 Nov 2023 17:25:05 +0000 Subject: [PATCH 02/11] runtime-rs: Update list of config paths to check Update the `DEFAULT_RUNTIME_CONFIGURATIONS` list to include a number of rust runtime specific paths to try to load before checking the "traditional" (golang) runtime configuration paths. Signed-off-by: James O. D. Hunt --- src/libs/kata-types/src/config/default.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libs/kata-types/src/config/default.rs b/src/libs/kata-types/src/config/default.rs index f55f597da2..ca95fcbc3c 100644 --- a/src/libs/kata-types/src/config/default.rs +++ b/src/libs/kata-types/src/config/default.rs @@ -14,6 +14,12 @@ use lazy_static::lazy_static; lazy_static! { /// Default configuration file paths, vendor may extend the list pub static ref DEFAULT_RUNTIME_CONFIGURATIONS: Vec::<&'static str> = vec![ + // The rust runtime specific paths + "/etc/kata-containers/runtime-rs/configuration.toml", + "/usr/share/defaults/kata-containers/runtime-rs/configuration.toml", + "/opt/kata/share/defaults/kata-containers/runtime-rs/configuration.toml", + + // The traditional golang paths "/etc/kata-containers/configuration.toml", "/usr/share/defaults/kata-containers/configuration.toml", "/opt/kata/share/defaults/kata-containers/configuration.toml", From 80860478bf92449eded7fdd04129f263cea6f07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 23 Nov 2023 10:18:44 +0100 Subject: [PATCH 03/11] runtime-rs: Remove the golang config paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the configuration files are different, we can safely remove those as any new installation of the binary should also bring in the new configurations. This makes things less error-prone in the future, as we're ensuring that the rust runtime will only be reading the rust configuration files. Signed-off-by: Fabiano Fidêncio --- src/libs/kata-types/src/config/default.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/libs/kata-types/src/config/default.rs b/src/libs/kata-types/src/config/default.rs index ca95fcbc3c..73f368e4f1 100644 --- a/src/libs/kata-types/src/config/default.rs +++ b/src/libs/kata-types/src/config/default.rs @@ -18,11 +18,6 @@ lazy_static! { "/etc/kata-containers/runtime-rs/configuration.toml", "/usr/share/defaults/kata-containers/runtime-rs/configuration.toml", "/opt/kata/share/defaults/kata-containers/runtime-rs/configuration.toml", - - // The traditional golang paths - "/etc/kata-containers/configuration.toml", - "/usr/share/defaults/kata-containers/configuration.toml", - "/opt/kata/share/defaults/kata-containers/configuration.toml", ]; } From fc28deee0efebe42a1fa682e68594a7aaa45d93b Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 14 Nov 2023 17:15:59 +0000 Subject: [PATCH 04/11] 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 --- .../kata-deploy/scripts/kata-deploy.sh | 48 +++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 178a33279c..e8555fe55b 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -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 < Date: Thu, 23 Nov 2023 10:16:29 +0100 Subject: [PATCH 05/11] kata-deploy: Improve the logic for linking to the rust runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change for now doesn't do much, apart from making it easier to expand which runtimes should be linked to the runtime-rs containerd shim binary. Also, this matches the logic used for the config files. Signed-off-by: Fabiano Fidêncio --- tools/packaging/kata-deploy/scripts/kata-deploy.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index e8555fe55b..4836650339 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -244,11 +244,15 @@ function configure_different_shims_base() { backup_shim "${shim_file}" - if [[ "${shim}" == "dragonball" ]]; then - ln -sf /opt/kata/runtime-rs/bin/containerd-shim-kata-v2 "${shim_file}" - else - ln -sf /opt/kata/bin/containerd-shim-kata-v2 "${shim_file}" - fi + # Map the runtime shim name to the appropriate + # containerd-shim-kata-v2 binary + case "$shim" in + dragonball) + ln -sf /opt/kata/runtime-rs/bin/containerd-shim-kata-v2 "${shim_file}" ;; + *) + ln -sf /opt/kata/bin/containerd-shim-kata-v2 "${shim_file}" ;; + esac + chmod +x "$shim_file" if [ "${shim}" == "${default_shim}" ]; then From 158ca17ae7a6ee1653d8e1060e8d065a86f078b8 Mon Sep 17 00:00:00 2001 From: "James O. D. Hunt" Date: Tue, 14 Nov 2023 17:09:25 +0000 Subject: [PATCH 06/11] kata-deploy: Add cloud-hypervisor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that we have a separate Cloud Hypervisor configuration file for the rust runtime, add it to the kata-deploy. See: https://github.com/kata-containers/kata-containers/pull/8250 Signed-off-by: James O. D. Hunt Signed-off-by: Fabiano Fidêncio --- .../kata-deploy/kata-cleanup/base/kata-cleanup.yaml | 2 +- .../kata-deploy/base/kata-deploy-stable.yaml | 2 +- .../kata-deploy/kata-deploy/base/kata-deploy.yaml | 2 +- .../runtimeclasses/kata-cloud-hypervisor.yaml | 13 +++++++++++++ .../runtimeclasses/kata-runtimeClasses.yaml | 13 +++++++++++++ tools/packaging/kata-deploy/scripts/kata-deploy.sh | 4 ++-- 6 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 tools/packaging/kata-deploy/runtimeclasses/kata-cloud-hypervisor.yaml 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 df7b715a9e..7239cdf8b5 100644 --- a/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml +++ b/tools/packaging/kata-deploy/kata-cleanup/base/kata-cleanup.yaml @@ -30,7 +30,7 @@ spec: - name: DEBUG value: "false" - name: SHIMS - value: "clh dragonball fc qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx qemu remote stratovirt" + value: "clh cloud-hypervisor dragonball fc qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx qemu stratovirt" - name: DEFAULT_SHIM value: "qemu" - name: CREATE_RUNTIMECLASSES diff --git a/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy-stable.yaml b/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy-stable.yaml index aa466cfc6f..cf78b8e5c7 100644 --- a/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy-stable.yaml +++ b/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy-stable.yaml @@ -32,7 +32,7 @@ spec: - name: DEBUG value: "false" - name: SHIMS - value: "clh dragonball fc qemu qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx" + value: "clh cloud-hypervisor dragonball fc qemu qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx" - name: DEFAULT_SHIM value: "qemu" - name: CREATE_RUNTIMECLASSES 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 03cbe4a53e..e746c6f32b 100644 --- a/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml +++ b/tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml @@ -32,7 +32,7 @@ spec: - name: DEBUG value: "false" - name: SHIMS - value: "clh dragonball fc qemu qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx remote stratovirt" + value: "clh cloud-hypervisor dragonball fc qemu qemu-nvidia-gpu qemu-sev qemu-snp qemu-tdx stratovirt" - name: DEFAULT_SHIM value: "qemu" - name: CREATE_RUNTIMECLASSES diff --git a/tools/packaging/kata-deploy/runtimeclasses/kata-cloud-hypervisor.yaml b/tools/packaging/kata-deploy/runtimeclasses/kata-cloud-hypervisor.yaml new file mode 100644 index 0000000000..c9c16aa882 --- /dev/null +++ b/tools/packaging/kata-deploy/runtimeclasses/kata-cloud-hypervisor.yaml @@ -0,0 +1,13 @@ +--- +kind: RuntimeClass +apiVersion: node.k8s.io/v1 +metadata: + name: kata-cloud-hypervisor +handler: kata-cloud-hypervisor +overhead: + podFixed: + memory: "130Mi" + cpu: "250m" +scheduling: + nodeSelector: + katacontainers.io/kata-runtime: "true" diff --git a/tools/packaging/kata-deploy/runtimeclasses/kata-runtimeClasses.yaml b/tools/packaging/kata-deploy/runtimeclasses/kata-runtimeClasses.yaml index 8736ad6325..b96ac44f8e 100644 --- a/tools/packaging/kata-deploy/runtimeclasses/kata-runtimeClasses.yaml +++ b/tools/packaging/kata-deploy/runtimeclasses/kata-runtimeClasses.yaml @@ -14,6 +14,19 @@ scheduling: --- kind: RuntimeClass apiVersion: node.k8s.io/v1 +metadata: + name: kata-cloud-hypervisor +handler: kata-cloud-hypervisor +overhead: + podFixed: + memory: "130Mi" + cpu: "250m" +scheduling: + nodeSelector: + katacontainers.io/kata-runtime: "true" +--- +kind: RuntimeClass +apiVersion: node.k8s.io/v1 metadata: name: kata-dragonball handler: kata-dragonball diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 4836650339..58517480f6 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -134,7 +134,7 @@ function get_kata_containers_config_path() { # Map the runtime shim name to the appropriate configuration # file directory. case "$shim" in - dragonball) config_path="$rust_config_path" ;; + cloud-hypervisor | dragonball) config_path="$rust_config_path" ;; *) config_path="$golang_config_path" ;; esac @@ -247,7 +247,7 @@ function configure_different_shims_base() { # Map the runtime shim name to the appropriate # containerd-shim-kata-v2 binary case "$shim" in - dragonball) + cloud-hypervisor | dragonball) ln -sf /opt/kata/runtime-rs/bin/containerd-shim-kata-v2 "${shim_file}" ;; *) ln -sf /opt/kata/bin/containerd-shim-kata-v2 "${shim_file}" ;; From 61aa84b158313c4e34a43a4fa4f3a95bdfa75518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Thu, 23 Nov 2023 11:13:54 +0100 Subject: [PATCH 07/11] Revert "tests: k8s: Allow passing rust-runtime env var to kata-deploy" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 44899d4cdf6aca72849c12ee4d8af1ceca97ffac, as we've decided to keep both golang and rust runtime installable and usable at the same time. The decision of having both runtimes installable and usable will help users to test and easily catch any possible differences between those runtimes, helping us to get on par with both implementations. Signed-off-by: Fabiano Fidêncio --- .github/workflows/run-k8s-tests-on-aks.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/run-k8s-tests-on-aks.yaml b/.github/workflows/run-k8s-tests-on-aks.yaml index e275869796..aea0a02406 100644 --- a/.github/workflows/run-k8s-tests-on-aks.yaml +++ b/.github/workflows/run-k8s-tests-on-aks.yaml @@ -27,8 +27,6 @@ jobs: strategy: fail-fast: false matrix: - rust-runtime: - - false host_os: - ubuntu vmm: @@ -42,8 +40,6 @@ jobs: include: - host_os: cbl-mariner vmm: clh - - dragonball: - rust-runtime: true runs-on: ubuntu-latest env: DOCKER_REGISTRY: ${{ inputs.registry }} @@ -55,7 +51,6 @@ jobs: KUBERNETES: "vanilla" USING_NFD: "false" K8S_TEST_HOST_TYPE: ${{ matrix.instance-type }} - RUST_RUNTIME: ${{ matrix.rust-runtime }} steps: - uses: actions/checkout@v4 with: From 30acb5a0c00de91925be3609b805608e28f7f671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Tue, 28 Nov 2023 15:15:10 +0100 Subject: [PATCH 08/11] tests: nydus: Adapt the default config file for runtime-rs based drivers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we've done some changes in the runtime-rs based drivers to install their configuration into a different location, this should also be reflected as part of this test. Signed-off-by: Fabiano Fidêncio --- tests/integration/nydus/nydus_tests.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/integration/nydus/nydus_tests.sh b/tests/integration/nydus/nydus_tests.sh index 9e3f655b9c..41a4cbbfc5 100755 --- a/tests/integration/nydus/nydus_tests.sh +++ b/tests/integration/nydus/nydus_tests.sh @@ -21,7 +21,7 @@ kata_config_backup="/tmp/kata-configuration.toml" SYSCONFIG_FILE="/etc/kata-containers/configuration.toml" DEFAULT_CONFIG_FILE="/opt/kata/share/defaults/kata-containers/configuration-qemu.toml" CLH_CONFIG_FILE="/opt/kata/share/defaults/kata-containers/configuration-clh.toml" -DB_CONFIG_FILE="/opt/kata/share/defaults/kata-containers/configuration-dragonball.toml" +DB_CONFIG_FILE="/opt/kata/share/defaults/kata-containers/runtime-rs/configuration-dragonball.toml" need_restore_containerd_config=false containerd_config="/etc/containerd/config.toml" containerd_config_backup="/tmp/containerd.config.toml" @@ -34,6 +34,14 @@ if [ "$KATA_HYPERVISOR" != "qemu" ] && [ "$KATA_HYPERVISOR" != "clh" ] && [ "$KA exit 0 fi +case "$KATA_HYPERVISOR" in + dragonball) + SYSCONFIG_FILE="/etc/kata-containers/runtime-rs/configuration.toml" + ;; + *) + ;; +esac + function setup_nydus() { # Config nydus snapshotter sudo -E cp "$dir_path/nydusd-config.json" /etc/ @@ -46,7 +54,7 @@ function setup_nydus() { } function config_kata() { - sudo mkdir -p /etc/kata-containers + sudo mkdir -p $(dirname $SYSCONFIG_FILE) if [ -f "$SYSCONFIG_FILE" ]; then need_restore_kata_config=true sudo cp -a "${SYSCONFIG_FILE}" "${kata_config_backup}" From a5a73a11cb1da63d5e5225dd4333cb08f7d86e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 29 Nov 2023 10:04:11 +0100 Subject: [PATCH 09/11] tests: Replace `kata-runtime kata-env` by `kata-runtime env` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `kata-runtime env` is an alias for `kata-runtime kata-env, and calling it with the `env` paramenter allows us to easily extend the scripts to use `kata-ctl` instead of `kata-runtime` when dealing with runtime-rs. Signed-off-by: Fabiano Fidêncio --- tests/common.bash | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/common.bash b/tests/common.bash index 9e9025bbf4..d858748bb8 100644 --- a/tests/common.bash +++ b/tests/common.bash @@ -80,23 +80,23 @@ function is_a_kata_runtime() { # Gets versions and paths of all the components # list in kata-env function extract_kata_env() { - RUNTIME_CONFIG_PATH=$(kata-runtime kata-env --json | jq -r .Runtime.Config.Path) - RUNTIME_VERSION=$(kata-runtime kata-env --json | jq -r .Runtime.Version | grep Semver | cut -d'"' -f4) - RUNTIME_COMMIT=$(kata-runtime kata-env --json | jq -r .Runtime.Version | grep Commit | cut -d'"' -f4) - RUNTIME_PATH=$(kata-runtime kata-env --json | jq -r .Runtime.Path) + RUNTIME_CONFIG_PATH=$(kata-runtime env --json | jq -r .Runtime.Config.Path) + RUNTIME_VERSION=$(kata-runtime env --json | jq -r .Runtime.Version | grep Semver | cut -d'"' -f4) + RUNTIME_COMMIT=$(kata-runtime env --json | jq -r .Runtime.Version | grep Commit | cut -d'"' -f4) + RUNTIME_PATH=$(kata-runtime env --json | jq -r .Runtime.Path) # Shimv2 path is being affected by https://github.com/kata-containers/kata-containers/issues/1151 SHIM_PATH=$(readlink $(command -v containerd-shim-kata-v2)) SHIM_VERSION=${RUNTIME_VERSION} - HYPERVISOR_PATH=$(kata-runtime kata-env --json | jq -r .Hypervisor.Path) + HYPERVISOR_PATH=$(kata-runtime env --json | jq -r .Hypervisor.Path) # TODO: there is no kata-runtime of rust version currently if [ "${KATA_HYPERVISOR}" != "dragonball" ]; then HYPERVISOR_VERSION=$(sudo -E ${HYPERVISOR_PATH} --version | head -n1) fi - VIRTIOFSD_PATH=$(kata-runtime kata-env --json | jq -r .Hypervisor.VirtioFSDaemon) + VIRTIOFSD_PATH=$(kata-runtime env --json | jq -r .Hypervisor.VirtioFSDaemon) - INITRD_PATH=$(kata-runtime kata-env --json | jq -r .Initrd.Path) + INITRD_PATH=$(kata-runtime env --json | jq -r .Initrd.Path) } # Checks that processes are not running @@ -105,8 +105,8 @@ function check_processes() { # Only check the kata-env if we have managed to find the kata executable... if [ -x "$RUNTIME_PATH" ]; then - local vsock_configured=$($RUNTIME_PATH kata-env | awk '/UseVSock/ {print $3}') - local vsock_supported=$($RUNTIME_PATH kata-env | awk '/SupportVSock/ {print $3}') + local vsock_configured=$($RUNTIME_PATH env | awk '/UseVSock/ {print $3}') + local vsock_supported=$($RUNTIME_PATH env | awk '/SupportVSock/ {print $3}') else local vsock_configured="false" local vsock_supported="false" From 38183acbcbc01a3ba673c331ab8098c937f54cee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 29 Nov 2023 10:07:56 +0100 Subject: [PATCH 10/11] tests: Use `kata-ctl` instead of `kata-runtime` for runtime-rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `kata-ctl` is the tool for runtime-rs, and it should be used instead of `kata-runtime`. `kata-ctl` requires sudo, and that's the reason it's also been added as part of the calls. Signed-off-by: Fabiano Fidêncio --- tests/common.bash | 49 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/tests/common.bash b/tests/common.bash index d858748bb8..e0c9490fb6 100644 --- a/tests/common.bash +++ b/tests/common.bash @@ -80,23 +80,56 @@ function is_a_kata_runtime() { # Gets versions and paths of all the components # list in kata-env function extract_kata_env() { - RUNTIME_CONFIG_PATH=$(kata-runtime env --json | jq -r .Runtime.Config.Path) - RUNTIME_VERSION=$(kata-runtime env --json | jq -r .Runtime.Version | grep Semver | cut -d'"' -f4) - RUNTIME_COMMIT=$(kata-runtime env --json | jq -r .Runtime.Version | grep Commit | cut -d'"' -f4) - RUNTIME_PATH=$(kata-runtime env --json | jq -r .Runtime.Path) + local cmd + local config_path + local runtime_version + local runtime_version_semver + local runtime_version_commit + local runtime_path + local hypervisor_path + local virtiofsd_path + local initrd_path + case "${KATA_HYPERVISOR}" in + dragonball) + cmd=kata-ctl + config_path=".runtime.config.path" + runtime_version=".runtime.version" + runtime_version_semver="semver" + runtime_version_commit="commit" + runtime_path=".runtime.path" + hypervisor_path=".hypervisor.path" + virtio_fs_daemon_path=".hypervisor.virtio_fs_daemon" + initrd_path=".initrd.path" + ;; + *) + cmd=kata-runtime + config_path=".Runtime.Config.Path" + runtime_version=".Runtime.Version" + runtime_version_semver="Semver" + runtime_version_commit="Commit" + runtime_path=".Runtime.Path" + hypervisor_path=".Hypervisor.Path" + virtio_fs_daemon_path=".Hypervisor.VirtioFSDaemon" + initrd_path=".Initrd.Path" + ;; + esac + RUNTIME_CONFIG_PATH=$(sudo ${cmd} env --json | jq -r ${config_path}) + RUNTIME_VERSION=$(sudo ${cmd} env --json | jq -r ${runtime_version} | grep ${runtime_version_semver} | cut -d'"' -f4) + RUNTIME_COMMIT=$(sudo ${cmd} env --json | jq -r ${runtime_version} | grep ${runtime_version_commit} | cut -d'"' -f4) + RUNTIME_PATH=$(sudo ${cmd} env --json | jq -r ${runtime_path}) # Shimv2 path is being affected by https://github.com/kata-containers/kata-containers/issues/1151 SHIM_PATH=$(readlink $(command -v containerd-shim-kata-v2)) SHIM_VERSION=${RUNTIME_VERSION} - HYPERVISOR_PATH=$(kata-runtime env --json | jq -r .Hypervisor.Path) - # TODO: there is no kata-runtime of rust version currently + HYPERVISOR_PATH=$(sudo ${cmd} env --json | jq -r ${hypervisor_path}) + # TODO: there is no ${cmd} of rust version currently if [ "${KATA_HYPERVISOR}" != "dragonball" ]; then HYPERVISOR_VERSION=$(sudo -E ${HYPERVISOR_PATH} --version | head -n1) fi - VIRTIOFSD_PATH=$(kata-runtime env --json | jq -r .Hypervisor.VirtioFSDaemon) + VIRTIOFSD_PATH=$(sudo ${cmd} env --json | jq -r ${virtio_fs_daemon_path}) - INITRD_PATH=$(kata-runtime env --json | jq -r .Initrd.Path) + INITRD_PATH=$(sudo ${cmd} env --json | jq -r ${initrd_path}) } # Checks that processes are not running From 8fd39d11c40bd3a0919e577adae46015f56abcba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 29 Nov 2023 10:10:39 +0100 Subject: [PATCH 11/11] tests: Adapt `enable_hypervisor`to the runtime-rs config location change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the configuration for the runtime-rs based drivers are now placed in a different location than the golang ones, we should adapt this script accordingly. Signed-off-by: Fabiano Fidêncio --- tests/common.bash | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/common.bash b/tests/common.bash index e0c9490fb6..e3b1e67398 100644 --- a/tests/common.bash +++ b/tests/common.bash @@ -399,16 +399,21 @@ function install_kata() { # points to the hypervisor passed by KATA_HYPERVISOR env var. function enabling_hypervisor() { declare -r KATA_DIR="/opt/kata" - declare -r CONFIG_DIR="${KATA_DIR}/share/defaults/kata-containers" - declare -r SRC_HYPERVISOR_CONFIG="${CONFIG_DIR}/configuration-${KATA_HYPERVISOR}.toml" - declare -r DEST_KATA_CONFIG="${CONFIG_DIR}/configuration.toml" declare -r CONTAINERD_SHIM_KATA="/usr/local/bin/containerd-shim-kata-${KATA_HYPERVISOR}-v2" - if [[ ${KATA_HYPERVISOR} == "dragonball" ]]; then - sudo ln -sf "${KATA_DIR}/runtime-rs/bin/containerd-shim-kata-v2" "${CONTAINERD_SHIM_KATA}" - else - sudo ln -sf "${KATA_DIR}/bin/containerd-shim-kata-v2" "${CONTAINERD_SHIM_KATA}" - fi + case "${KATA_HYPERVISOR}" in + dragonball) + sudo ln -sf "${KATA_DIR}/runtime-rs/bin/containerd-shim-kata-v2" "${CONTAINERD_SHIM_KATA}" + declare -r CONFIG_DIR="${KATA_DIR}/share/defaults/kata-containers/runtime-rs" + ;; + *) + sudo ln -sf "${KATA_DIR}/bin/containerd-shim-kata-v2" "${CONTAINERD_SHIM_KATA}" + declare -r CONFIG_DIR="${KATA_DIR}/share/defaults/kata-containers" + ;; + esac + + declare -r SRC_HYPERVISOR_CONFIG="${CONFIG_DIR}/configuration-${KATA_HYPERVISOR}.toml" + declare -r DEST_KATA_CONFIG="${CONFIG_DIR}/configuration.toml" sudo ln -sf "${SRC_HYPERVISOR_CONFIG}" "${DEST_KATA_CONFIG}" }