gha: k8s: reject unsupported KATA_HYPERVISOR values

Exit early with an error message instead of starting kata-deploy if
the value of KATA_HYPERVISOR is not expected during CI.

For example: "cloud-hypervisor" was renamed recently to
"clh-runtime-rs" and user scripts depending on the old name were
getting tangled in kata-deploy instead of just rejecting the old
value quickly.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
Dan Mihai
2026-05-16 00:23:19 +00:00
parent 0f3df5d1e4
commit ddc36060d2
2 changed files with 25 additions and 0 deletions

View File

@@ -13,6 +13,19 @@ TEE_HYPERVISORS=("${SNP_HYPERVISORS[@]}" "${TDX_HYPERVISORS[@]}" "${SE_HYPERVISO
NON_TEE_HYPERVISORS=("qemu-coco-dev" "qemu-coco-dev-runtime-rs")
FIRECRACKER_HYPERVISORS=("firecracker" "fc")
ALL_HYPERVISORS=(
"clh"
"clh-runtime-rs"
"dragonball"
"qemu"
"qemu-runtime-rs"
"qemu-nvidia-gpu"
"qemu-nvidia-gpu-runtime-rs"
"${TEE_HYPERVISORS[@]}"
"${NON_TEE_HYPERVISORS[@]}"
"${FIRECRACKER_HYPERVISORS[@]}"
)
function is_snp_hypervisor() {
local hypervisor="${1:-${KATA_HYPERVISOR}}"
# shellcheck disable=SC2076 # intentionally use literal string matching
@@ -62,6 +75,13 @@ function is_firecracker_hypervisor() {
return 1
}
function is_supported_hypervisor() {
local hypervisor="${1:-${KATA_HYPERVISOR}}"
# shellcheck disable=SC2076 # intentionally use literal string matching
[[ " ${ALL_HYPERVISORS[*]} " =~ " ${hypervisor} " ]] && return 0
return 1
}
# Common check for confidential hardware (TEE) runtime class.
function is_confidential_hardware() {
local hypervisor="${1:-${KATA_HYPERVISOR}}"

View File

@@ -177,6 +177,11 @@ function deploy_coco_kbs() {
function deploy_kata() {
platform="${1:-}"
if ! is_supported_hypervisor "${KATA_HYPERVISOR}" ; then
# shellcheck disable=SC2154
die "Unsupported KATA_HYPERVISOR=${KATA_HYPERVISOR}. Supported values: ${ALL_HYPERVISORS[*]}"
fi
[[ "${platform}" = "kcli" ]] && \
export KUBECONFIG="${HOME}/.kcli/clusters/${CLUSTER_NAME:-kata-k8s}/auth/kubeconfig"