From 915bace795b23c0f9b16b3a2bd565c1fe2fefcbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bombo?= Date: Wed, 16 Aug 2023 11:01:08 -0700 Subject: [PATCH] kata-deploy: Properly create default runtime class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The default `kata` runtime class would get created with the `kata` handler instead of `kata-$KATA_HYPERVISOR`. This made Kata use the wrong hypervisor and broke CI. Fixes: #7663 Signed-off-by: Aurélien Bombo (cherry picked from commit 339569b69c4a67e0ab37c13501f6693023a7dc85) --- .../kata-deploy-ensure-runtimec-classes-created.bats | 12 +++++++++++- tools/packaging/kata-deploy/scripts/kata-deploy.sh | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/integration/kubernetes/kata-deploy-ensure-runtimec-classes-created.bats b/tests/integration/kubernetes/kata-deploy-ensure-runtimec-classes-created.bats index bd1d5a1517..b2ec3c330b 100644 --- a/tests/integration/kubernetes/kata-deploy-ensure-runtimec-classes-created.bats +++ b/tests/integration/kubernetes/kata-deploy-ensure-runtimec-classes-created.bats @@ -14,13 +14,23 @@ setup() { # * `kata-${KATA_HYPERVISOR}` is the other one # * As part of the tests we're only deploying the specific runtimeclass that will be used, instead of all of them. expected_runtime_classes=2 + + # We expect both runtime classes to have the same handler: kata-${KATA_HYPERVISOR} + expected_handlers_re=( \ + "kata\s+kata-${KATA_HYPERVISOR}" \ + "kata-${KATA_HYPERVISOR}\s+kata-${KATA_HYPERVISOR}" \ + ) } @test "Test runtimeclasses are being properly created" { # We filter `kata-mshv-vm-isolation` out as that's present on AKS clusters, but that's not coming from kata-deploy current_runtime_classes=$(kubectl get runtimeclasses | grep -v "kata-mshv-vm-isolation" | grep "kata" | wc -l) [[ ${current_runtime_classes} -eq ${expected_runtime_classes} ]] - [[ $(kubectl get runtimeclasses | grep -q "${KATA_HYPERVISOR}") -eq 0 ]] + + for handler_re in ${expected_handlers_re[@]} + do + [[ $(kubectl get runtimeclass | grep -E "${handler_re}") ]] + done } teardown() { diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index fc26921df2..5f7d253319 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -44,7 +44,7 @@ function create_runtimeclasses() { if [[ "${CREATE_DEFAULT_RUNTIMECLASS}" == "true" ]]; then echo "Creating the kata runtime class for the default shim (an alias for kata-${default_shim})" cp /opt/kata-artifacts/runtimeclasses/kata-${default_shim}.yaml /tmp/kata.yaml - sed -i -e 's/kata-'${default_shim}'/kata/g' /tmp/kata.yaml + sed -i -e 's/name: kata-'${default_shim}'/name: kata/g' /tmp/kata.yaml kubectl apply -f /tmp/kata.yaml rm -f /tmp/kata.yaml fi @@ -62,7 +62,7 @@ function delete_runtimeclasses() { if [[ "${CREATE_DEFAULT_RUNTIMECLASS}" == "true" ]]; then echo "Deleting the kata runtime class for the default shim (an alias for kata-${default_shim})" cp /opt/kata-artifacts/runtimeclasses/kata-${default_shim}.yaml /tmp/kata.yaml - sed -i -e 's/kata-'${default_shim}'/kata/g' /tmp/kata.yaml + sed -i -e 's/name: kata-'${default_shim}'/name: kata/g' /tmp/kata.yaml kubectl delete -f /tmp/kata.yaml rm -f /tmp/kata.yaml fi