From 9c54a9c005a8cf30b791719303ff0c28b8a02b51 Mon Sep 17 00:00:00 2001 From: Le Zhang Date: Thu, 18 Jul 2024 13:59:12 -0400 Subject: [PATCH] Issue open-horizon#4108 - Feature Request: Fail on agent-install.sh for k8s agent if storage class is invalid Signed-off-by: Le Zhang --- agent-install/agent-install.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/agent-install/agent-install.sh b/agent-install/agent-install.sh index 91b849108..f38aced78 100755 --- a/agent-install/agent-install.sh +++ b/agent-install/agent-install.sh @@ -1254,6 +1254,8 @@ function get_all_variables() { # get other variables for cluster agent get_variable EDGE_CLUSTER_STORAGE_CLASS 'gp2' + check_cluster_storage_class "$EDGE_CLUSTER_STORAGE_CLASS" + get_variable AGENT_NAMESPACE "$DEFAULT_AGENT_NAMESPACE" get_variable NAMESPACE_SCOPED 'false' get_variable USE_EDGE_CLUSTER_REGISTRY 'true' @@ -3304,6 +3306,18 @@ function get_cluster_image_arch() { echo $image_arch } +# check if the storage class exists in the edge cluster +function check_cluster_storage_class() { + log_debug "check_cluster_storage_class() begin" + local storage_class=$1 + if $KUBECTL get storageclass ${storage_class} >/dev/null 2>&1; then + log_verbose "storage class $storage_class exists in the edge cluster" + else + log_fatal 2 "storage class $storage_class does not exist in the edge cluster" + fi + log_debug "check_cluster_storage_class() end" +} + # checks if OS/distribution/codename/arch is supported function check_support() { log_debug "check_support() begin"