From 8f46ada614bd452839ad28cdeee4dc02e271ab7e Mon Sep 17 00:00:00 2001 From: Rafael Vasquez Date: Tue, 22 Aug 2023 15:48:44 -0400 Subject: [PATCH 1/6] Use namespace flag during deletion Signed-off-by: Rafael Vasquez --- scripts/delete.sh | 6 ++++-- scripts/install.sh | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/delete.sh b/scripts/delete.sh index a8ebbfa5..b1ee819c 100755 --- a/scripts/delete.sh +++ b/scripts/delete.sh @@ -133,11 +133,13 @@ if [[ "$crb_ns" == "$namespace" ]]; then fi 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 [[ $(kubectl exec deploy/modelmesh-controller -- printenv NAMESPACE_SCOPE) == 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 # Roll back to previous status if [[ "$namespace" != "$old_namespace" ]]; then kubectl config set-context --current --namespace=${old_namespace} -fi +fi \ No newline at end of file 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 From 8feb2107b71b93a46dc736539ecde4f2ee2dcd8e Mon Sep 17 00:00:00 2001 From: Rafael Vasquez Date: Tue, 22 Aug 2023 15:59:22 -0400 Subject: [PATCH 2/6] Keep newline Signed-off-by: Rafael Vasquez --- scripts/delete.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/delete.sh b/scripts/delete.sh index b1ee819c..514d60e3 100755 --- a/scripts/delete.sh +++ b/scripts/delete.sh @@ -142,4 +142,4 @@ kubectl delete -f dependencies/fvt.yaml --ignore-not-found=true # Roll back to previous status if [[ "$namespace" != "$old_namespace" ]]; then kubectl config set-context --current --namespace=${old_namespace} -fi \ No newline at end of file +fi From ec9c3f87f789f373e184a4edd58de6ba1ab722ee Mon Sep 17 00:00:00 2001 From: Rafael Vasquez Date: Wed, 23 Aug 2023 15:22:15 -0400 Subject: [PATCH 3/6] Fix logic Signed-off-by: Rafael Vasquez --- scripts/delete.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/delete.sh b/scripts/delete.sh index 514d60e3..14aae15d 100755 --- a/scripts/delete.sh +++ b/scripts/delete.sh @@ -131,15 +131,19 @@ 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) kustomize build default | kubectl delete -f - --ignore-not-found=true kustomize build rbac/namespace-scope | kubectl delete -f - --ignore-not-found=true -if [[ $(kubectl exec deploy/modelmesh-controller -- printenv NAMESPACE_SCOPE) == true ]]; then - kustomize build runtimes ${kustomize_load_restrictor_arg} | kubectl delete -f - --ignore-not-found=true +if [[ ! $is_namespace_scoped ]]; then + kustomize build runtimes --load_restrictor none | kubectl apply -f - fi + kubectl delete -f dependencies/quickstart.yaml --ignore-not-found=true kubectl delete -f dependencies/fvt.yaml --ignore-not-found=true # Roll back to previous status if [[ "$namespace" != "$old_namespace" ]]; then kubectl config set-context --current --namespace=${old_namespace} -fi +fi \ No newline at end of file From c93a85d9fc971bfedc614059ba8ba5b061e49763 Mon Sep 17 00:00:00 2001 From: Rafael Vasquez Date: Wed, 23 Aug 2023 15:23:50 -0400 Subject: [PATCH 4/6] Lints Signed-off-by: Rafael Vasquez --- scripts/delete.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/delete.sh b/scripts/delete.sh index 14aae15d..2970b85e 100755 --- a/scripts/delete.sh +++ b/scripts/delete.sh @@ -146,4 +146,4 @@ kubectl delete -f dependencies/fvt.yaml --ignore-not-found=true # Roll back to previous status if [[ "$namespace" != "$old_namespace" ]]; then kubectl config set-context --current --namespace=${old_namespace} -fi \ No newline at end of file +fi From ad983ede90be24d532062f744fb5b7cd43d5d147 Mon Sep 17 00:00:00 2001 From: Rafael Vasquez Date: Thu, 7 Sep 2023 09:51:50 -0400 Subject: [PATCH 5/6] Fixes namescape check logic Signed-off-by: Rafael Vasquez --- scripts/delete.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/delete.sh b/scripts/delete.sh index 2970b85e..92e2de07 100755 --- a/scripts/delete.sh +++ b/scripts/delete.sh @@ -133,11 +133,11 @@ if [[ "$crb_ns" == "$namespace" ]]; then fi # Determine whether deployment is namespace-scoped before deleting runtime resources -is_namespace_scoped=$(kubectl exec deploy/modelmesh-controller -- printenv NAMESPACE_SCOPE) +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 -if [[ ! $is_namespace_scoped ]]; then - kustomize build runtimes --load_restrictor none | kubectl apply -f - +if [[ ! "$is_namespace_scoped" == "true" ]]; then + echo false fi kubectl delete -f dependencies/quickstart.yaml --ignore-not-found=true From e54e1c1792c988c1e07882086ce87d1ab7d53e2a Mon Sep 17 00:00:00 2001 From: Rafael Vasquez Date: Fri, 8 Sep 2023 10:42:05 -0400 Subject: [PATCH 6/6] Corrects dev accident Signed-off-by: Rafael Vasquez --- scripts/delete.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/delete.sh b/scripts/delete.sh index 92e2de07..698951eb 100755 --- a/scripts/delete.sh +++ b/scripts/delete.sh @@ -137,7 +137,7 @@ is_namespace_scoped=$(kubectl exec deploy/modelmesh-controller -- printenv NAMES kustomize build default | kubectl delete -f - --ignore-not-found=true kustomize build rbac/namespace-scope | kubectl delete -f - --ignore-not-found=true if [[ ! "$is_namespace_scoped" == "true" ]]; then - echo false + 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