From 0eaf81c1a2706bb47e6c86df095d26a4c6e9a2ee Mon Sep 17 00:00:00 2001 From: Wainer dos Santos Moschetta Date: Thu, 10 Aug 2023 17:30:22 -0300 Subject: [PATCH] tests: add get_one_kata_node() to tests_common.sh The introduced get_one_kata_node() returns the first node that has the kata-runtime=true label, i.e., supposedly a node with kata installed. This is useful for tests that should run on a determined worker node on a multi-nodes cluster. Fixes #7619 Signed-off-by: Wainer dos Santos Moschetta (cherry picked from commit 61c9c17bff5511dc419701398bf77aab0eb79b9f) --- tests/integration/kubernetes/tests_common.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/integration/kubernetes/tests_common.sh b/tests/integration/kubernetes/tests_common.sh index f932bd6561..079080338a 100644 --- a/tests/integration/kubernetes/tests_common.sh +++ b/tests/integration/kubernetes/tests_common.sh @@ -38,6 +38,14 @@ get_pod_config_dir() { info "k8s configured to use runtimeclass" } +# Return the first worker found that is kata-runtime labeled. +get_one_kata_node() { + local resource_name + resource_name="$(kubectl get node -l katacontainers.io/kata-runtime=true -o name | head -1)" + # Remove leading "/node" + echo "${resource_name/"node/"}" +} + # Runs a command in the host filesystem. exec_host() { node="$(kubectl get node -o name)"