gha: kata-deploy: Do the runtime class cleanup as part of the cleanup

Instead of doing this as part of the test itself, let's ensure it's done
before running the tests and during the tests cleanup.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2023-08-17 10:52:18 +02:00
parent 4ffc2c86f3
commit 2d896ad12f
2 changed files with 23 additions and 13 deletions

View File

@ -13,11 +13,34 @@ kata_deploy_dir="$(dirname "$(readlink -f "$0")")"
source "${kata_deploy_dir}/../../gha-run-k8s-common.sh"
function run_tests() {
cleanup_runtimeclasses || true
pushd "${kata_deploy_dir}"
bash run-kata-deploy-tests.sh
popd
}
function cleanup_runtimeclasses() {
# Cleanup any runtime class that was left behind in the cluster, in
# case of a test failure, apart from the default one that comes from
# AKS
for rc in `kubectl get runtimeclass -o name | grep -v "kata-mshv-vm-isolation" | sed 's|runtimeclass.node.k8s.io/||'`
do
kubectl delete runtimeclass $rc;
done
}
function cleanup() {
platform="${1}"
test_type="${2:-k8s}"
cleanup_runtimeclasses || true
if [ "${platform}" = "aks" ]; then
delete_cluster ${test_type}
fi
}
function main() {
export KATA_HOST_OS="${KATA_HOST_OS:-}"

View File

@ -11,12 +11,6 @@ setup() {
repo_root_dir="${BATS_TEST_DIRNAME}/../../../"
ensure_yq
# Cleanup any runtimeclass already present in the cluster
# apart from the default one that comes from AKS
for rc in `kubectl get runtimeclass -o name | grep -v "kata-mshv-vm-isolation" | sed 's|runtimeclass.node.k8s.io/||'`; do
kubectl delete runtimeclass $rc;
done
# We expect 2 runtime classes because:
# * `kata` is the default runtimeclass created, basically an alias for `kata-${KATA_HYPERVISOR}`.
# * `kata-${KATA_HYPERVISOR}` is the other one
@ -109,11 +103,4 @@ teardown() {
kubectl delete ${cleanup_spec}
kubectl delete -f "${repo_root_dir}/tools/packaging/kata-deploy/kata-rbac/base/kata-rbac.yaml"
# Cleanup any runtime class that was left behind in the cluster, in
# case of a test failure, apart from the default one that comes from
# AKS
for rc in `kubectl get runtimeclass -o name | grep -v "kata-mshv-vm-isolation" | sed 's|runtimeclass.node.k8s.io/||'`; do
kubectl delete runtimeclass $rc;
done
}