gha: Fix indentation in gha run k8s common

This PR fixes the indentation in gha run k8s common script
to have uniformity across the script.

Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
This commit is contained in:
Gabriela Cervantes 2024-05-13 20:07:47 +00:00
parent 4d5e90038c
commit f20a44bba3

View File

@ -12,38 +12,38 @@ GH_PR_NUMBER="${GH_PR_NUMBER:-}"
GENPOLICY_PULL_METHOD="${GENPOLICY_PULL_METHOD:-oci-distribution}" GENPOLICY_PULL_METHOD="${GENPOLICY_PULL_METHOD:-oci-distribution}"
function _print_instance_type() { function _print_instance_type() {
case ${K8S_TEST_HOST_TYPE} in case ${K8S_TEST_HOST_TYPE} in
small) small)
echo "Standard_D2s_v5" echo "Standard_D2s_v5"
;; ;;
normal) normal)
echo "Standard_D4s_v5" echo "Standard_D4s_v5"
;; ;;
*) *)
echo "Unknown instance type '${K8S_TEST_HOST_TYPE}'" >&2 echo "Unknown instance type '${K8S_TEST_HOST_TYPE}'" >&2
exit 1 exit 1
esac esac
} }
# Print the cluster name set by $AKS_NAME or generated out of runtime # Print the cluster name set by $AKS_NAME or generated out of runtime
# metadata (e.g. pull request number, commit SHA, etc). # metadata (e.g. pull request number, commit SHA, etc).
# #
function _print_cluster_name() { function _print_cluster_name() {
local test_type="${1:-k8s}" local test_type="${1:-k8s}"
local short_sha local short_sha
if [ -n "${AKS_NAME:-}" ]; then if [ -n "${AKS_NAME:-}" ]; then
echo "$AKS_NAME" echo "$AKS_NAME"
else else
short_sha="$(git rev-parse --short=12 HEAD)" short_sha="$(git rev-parse --short=12 HEAD)"
echo "${test_type}-${GH_PR_NUMBER}-${short_sha}-${KATA_HYPERVISOR}-${KATA_HOST_OS}-amd64-${K8S_TEST_HOST_TYPE:0:1}-${GENPOLICY_PULL_METHOD:0:1}" echo "${test_type}-${GH_PR_NUMBER}-${short_sha}-${KATA_HYPERVISOR}-${KATA_HOST_OS}-amd64-${K8S_TEST_HOST_TYPE:0:1}-${GENPOLICY_PULL_METHOD:0:1}"
fi fi
} }
function _print_rg_name() { function _print_rg_name() {
test_type="${1:-k8s}" test_type="${1:-k8s}"
echo "${AZ_RG:-"kataCI-$(_print_cluster_name ${test_type})"}" echo "${AZ_RG:-"kataCI-$(_print_cluster_name ${test_type})"}"
} }
# Enable the HTTP application routing add-on to AKS. # Enable the HTTP application routing add-on to AKS.
@ -62,56 +62,56 @@ function enable_cluster_http_application_routing() {
} }
function install_azure_cli() { function install_azure_cli() {
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
# The aks-preview extension is required while the Mariner Kata host is in preview. # The aks-preview extension is required while the Mariner Kata host is in preview.
az extension add --name aks-preview az extension add --name aks-preview
} }
function login_azure() { function login_azure() {
az login \ az login \
--service-principal \ --service-principal \
-u "${AZ_APPID}" \ -u "${AZ_APPID}" \
-p "${AZ_PASSWORD}" \ -p "${AZ_PASSWORD}" \
--tenant "${AZ_TENANT_ID}" --tenant "${AZ_TENANT_ID}"
# Switch to the Kata Containers subscription # Switch to the Kata Containers subscription
az account set --subscription "${AZ_SUBSCRIPTION_ID}" az account set --subscription "${AZ_SUBSCRIPTION_ID}"
} }
function create_cluster() { function create_cluster() {
test_type="${1:-k8s}" test_type="${1:-k8s}"
# First ensure it didn't fail to get cleaned up from a previous run. # First ensure it didn't fail to get cleaned up from a previous run.
delete_cluster "${test_type}" || true delete_cluster "${test_type}" || true
local rg="$(_print_rg_name ${test_type})" local rg="$(_print_rg_name ${test_type})"
az group create \ az group create \
-l eastus \ -l eastus \
-n "${rg}" -n "${rg}"
az aks create \ az aks create \
-g "${rg}" \ -g "${rg}" \
--node-resource-group "node-${rg}" \ --node-resource-group "node-${rg}" \
-n "$(_print_cluster_name ${test_type})" \ -n "$(_print_cluster_name ${test_type})" \
-s "$(_print_instance_type)" \ -s "$(_print_instance_type)" \
--node-count 1 \ --node-count 1 \
--generate-ssh-keys --generate-ssh-keys
} }
function install_bats() { function install_bats() {
# Installing bats from the lunar repo. # Installing bats from the lunar repo.
# This installs newer version of the bats which supports setup_file and teardown_file functions. # This installs newer version of the bats which supports setup_file and teardown_file functions.
# These functions are helpful when adding new tests that require one time setup. # These functions are helpful when adding new tests that require one time setup.
sudo apt install -y software-properties-common sudo apt install -y software-properties-common
sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ lunar universe' sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu/ lunar universe'
sudo apt install -y bats sudo apt install -y bats
sudo add-apt-repository --remove 'deb http://archive.ubuntu.com/ubuntu/ lunar universe' sudo add-apt-repository --remove 'deb http://archive.ubuntu.com/ubuntu/ lunar universe'
} }
function install_kubectl() { function install_kubectl() {
sudo az aks install-cli sudo az aks install-cli
} }
# Install the kustomize tool in /usr/local/bin if it doesn't exist on # Install the kustomize tool in /usr/local/bin if it doesn't exist on
@ -142,12 +142,12 @@ function install_kustomize() {
} }
function get_cluster_credentials() { function get_cluster_credentials() {
test_type="${1:-k8s}" test_type="${1:-k8s}"
az aks get-credentials \ az aks get-credentials \
--overwrite-existing \ --overwrite-existing \
-g "$(_print_rg_name ${test_type})" \ -g "$(_print_rg_name ${test_type})" \
-n "$(_print_cluster_name ${test_type})" -n "$(_print_cluster_name ${test_type})"
} }
@ -169,13 +169,13 @@ function get_cluster_specific_dns_zone() {
} }
function delete_cluster() { function delete_cluster() {
test_type="${1:-k8s}" test_type="${1:-k8s}"
local rg local rg
rg="$(_print_rg_name ${test_type})" rg="$(_print_rg_name ${test_type})"
if [ "$(az group exists -g "${rg}")" == "true" ]; then if [ "$(az group exists -g "${rg}")" == "true" ]; then
az group delete -g "${rg}" --yes az group delete -g "${rg}" --yes
fi fi
} }
function delete_cluster_kcli() { function delete_cluster_kcli() {
@ -184,8 +184,8 @@ function delete_cluster_kcli() {
} }
function get_nodes_and_pods_info() { function get_nodes_and_pods_info() {
kubectl debug $(kubectl get nodes -o name) -it --image=quay.io/kata-containers/kata-debug:latest || true kubectl debug $(kubectl get nodes -o name) -it --image=quay.io/kata-containers/kata-debug:latest || true
kubectl get pods -o name | grep node-debugger | xargs kubectl delete || true kubectl get pods -o name | grep node-debugger | xargs kubectl delete || true
} }
function deploy_k0s() { function deploy_k0s() {