From e0420336549753c9c7eaca6ec8a1b384fca9e3aa Mon Sep 17 00:00:00 2001 From: YuChen Shen <59578388+YCShen1010@users.noreply.github.com> Date: Fri, 22 Mar 2024 23:28:49 -0400 Subject: [PATCH] delete nss resrouces by patch finalizer (#1874) Signed-off-by: YuChen --- cp3pt0-deployment/common/utils.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cp3pt0-deployment/common/utils.sh b/cp3pt0-deployment/common/utils.sh index 42c6d7027..7d99adfb4 100644 --- a/cp3pt0-deployment/common/utils.sh +++ b/cp3pt0-deployment/common/utils.sh @@ -1084,7 +1084,14 @@ function cleanup_OperandBindInfo() { function cleanup_NamespaceScope() { local namespace=$1 - ${OC} delete namespacescope odlm-scope-managedby-odlm nss-odlm-scope nss-managedby-odlm common-service -n ${namespace} --ignore-not-found + local resources=("odlm-scope-managedby-odlm" "nss-odlm-scope" "nss-managedby-odlm" "common-service") + for resource in "${resources[@]}"; do + msg "Delete $resource in namespace $namespace..." + if ! ${OC} delete namespacescope $resource -n ${namespace} --ignore-not-found --timeout=10s > /dev/null 2>&1; then + warning "Deletion of $resource failed. Patching finalizer..." + ${OC} patch -n ${namespace} namespacescope $resource --type="json" -p '[{"op": "remove", "path":"/metadata/finalizers"}]' + fi + done } function cleanup_OperandRequest() {