From 7892e04dd1e1918bcfc1d674dfbede1c67be3bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bombo?= Date: Mon, 18 Sep 2023 09:23:30 -0700 Subject: [PATCH] ci: Add first letter of the K8S_TEST_HOST_TYPE to resource group name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ideally we'd add the instance_type or the full K8S_TEST_HOST_TYPE but that exceeds the maximum amount of characteres allowed for the cluster name. With this in mind, let's use the first letter of K8S_TEST_HOST_TYPE instead. Signed-off-by: Aurélien Bombo (cherry picked from commit d9ef1352af139030d760bedbaa860080a5f1d7aa) --- tests/gha-run-k8s-common.sh | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/gha-run-k8s-common.sh b/tests/gha-run-k8s-common.sh index cbd79c01c4..5b8193c88f 100644 --- a/tests/gha-run-k8s-common.sh +++ b/tests/gha-run-k8s-common.sh @@ -13,11 +13,25 @@ source "${tests_dir}/common.bash" K8S_TEST_HOST_TYPE="${K8S_TEST_HOST_TYPE:-small}" +function _print_instance_type() { + case ${K8S_TEST_HOST_TYPE} in + small) + echo "Standard_D2s_v5" + ;; + normal) + echo "Standard_D4s_v5" + ;; + *) + echo "Unknown instance type '${K8S_TEST_HOST_TYPE}'" >&2 + exit 1 + esac +} + function _print_cluster_name() { test_type="${1:-k8s}" short_sha="$(git rev-parse --short=12 HEAD)" - echo "${test_type}-${GH_PR_NUMBER}-${short_sha}-${KATA_HYPERVISOR}-${KATA_HOST_OS}-amd64" + echo "${test_type}-${GH_PR_NUMBER}-${short_sha}-${KATA_HYPERVISOR}-${KATA_HOST_OS}-amd64-${K8S_TEST_HOST_TYPE:0:1}" } function _print_rg_name() { @@ -52,21 +66,11 @@ function create_cluster() { -l eastus2 \ -n "${rg}" - local instance_type="" - case ${K8S_TEST_HOST_TYPE} in - small) - instance_type="Standard_D2s_v5" - ;; - normal) - instance_type="Standard_D4s_v5" - ;; - esac - az aks create \ -g "${rg}" \ --node-resource-group "node-${rg}" \ -n "$(_print_cluster_name ${test_type})" \ - -s "${instance_type}" \ + -s "$(_print_instance_type)" \ --node-count 1 \ --generate-ssh-keys \ $([ "${KATA_HOST_OS}" = "cbl-mariner" ] && echo "--os-sku AzureLinux --workload-runtime KataMshvVmIsolation")