From 5dfc2784c740c63736f52f88e309681795aa12a3 Mon Sep 17 00:00:00 2001 From: Rafael Vasquez Date: Fri, 8 Sep 2023 16:41:05 -0400 Subject: [PATCH] fix: Don't delete ClusterServingRuntime in namespace-scope mode (#421) Set NAMESPACE_SCOPE environment to true or false in install script and test NAMESPACE_SCOPE environment variable in delete script to check whether ClusterServingRuntime should be deleted. Resolves #420 --------- Signed-off-by: Rafael Vasquez --- scripts/delete.sh | 8 +++++++- scripts/install.sh | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/delete.sh b/scripts/delete.sh index a8ebbfa5..698951eb 100755 --- a/scripts/delete.sh +++ b/scripts/delete.sh @@ -131,9 +131,15 @@ if [[ "$crb_ns" == "$namespace" ]]; then echo "deleting cluster scope RBAC" kustomize build rbac/cluster-scope | kubectl delete -f - --ignore-not-found=true fi + +# Determine whether deployment is namespace-scoped before deleting runtime resources +is_namespace_scoped=$(kubectl exec deploy/modelmesh-controller -- printenv NAMESPACE_SCOPE 2> /dev/null || echo "false") || : kustomize build default | kubectl delete -f - --ignore-not-found=true kustomize build rbac/namespace-scope | kubectl delete -f - --ignore-not-found=true -kustomize build runtimes ${kustomize_load_restrictor_arg} | kubectl delete -f - --ignore-not-found=true +if [[ ! "$is_namespace_scoped" == "true" ]]; then + kustomize build runtimes ${kustomize_load_restrictor_arg} | kubectl delete -f - --ignore-not-found=true +fi + kubectl delete -f dependencies/quickstart.yaml --ignore-not-found=true kubectl delete -f dependencies/fvt.yaml --ignore-not-found=true diff --git a/scripts/install.sh b/scripts/install.sh index b9d1fafe..5cd0f0cc 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -351,6 +351,8 @@ if [[ $namespace_scope_mode == "true" ]]; then # Reset crd/kustomization.yaml back to CSR crd since we used the same file for namespace scope mode installation sed -i.bak 's/#- bases\/serving.kserve.io_clusterservingruntimes.yaml/- bases\/serving.kserve.io_clusterservingruntimes.yaml/g' crd/kustomization.yaml rm crd/kustomization.yaml.bak +else + kubectl set env deploy/modelmesh-controller NAMESPACE_SCOPE=false fi if [[ -n $modelmesh_serving_image ]]; then