From 64d88a189256bbe5381efb844040538317b16a62 Mon Sep 17 00:00:00 2001 From: Allen Li <46284272+qpdpQ@users.noreply.github.com> Date: Tue, 9 Jul 2024 10:30:43 -0400 Subject: [PATCH] skip clean control namespace in rerun (#2083) * skip clean control namespace in rerun Signed-off-by: Allen Li * null value for CONTROL_NS Signed-off-by: Allen Li --------- Signed-off-by: Allen Li --- cp3pt0-deployment/uninstall_tenant.sh | 39 +++++++++++++++------------ 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/cp3pt0-deployment/uninstall_tenant.sh b/cp3pt0-deployment/uninstall_tenant.sh index b9a2c3fbe..06c65d7b8 100755 --- a/cp3pt0-deployment/uninstall_tenant.sh +++ b/cp3pt0-deployment/uninstall_tenant.sh @@ -16,6 +16,7 @@ OC=oc YQ=yq TENANT_NAMESPACES="" OPERATOR_NS_LIST="" +CONTROL_NS="" FORCE_DELETE=0 DEBUG=0 @@ -369,24 +370,28 @@ function cleanup_cs_control() { title "Clean up control namespace" msg "-----------------------------------------------------------------------" get_control_namespace - # cleanup namespaceScope in Control namespace - cleanup_NamespaceScope $CONTROL_NS - # cleanup webhook - cleanup_webhook $CONTROL_NS "" - # cleanup secretshare - cleanup_secretshare $CONTROL_NS "" - # cleanup crossplane - cleanup_crossplane - # delete common-service-maps - ${OC} delete configmap common-service-maps -n kube-public - # delete namespace - ${OC} delete --ignore-not-found ns "$CONTROL_NS" --timeout=30s - if [ $? -ne 0 ] || [ $FORCE_DELETE -eq 1 ]; then - warning "Failed to delete namespace $CONTROL_NS, force deleting remaining resources..." - remove_all_finalizers $ns && success "Namespace $CONTROL_NS is deleted successfully." - fi + if [[ "${CONTROL_NS}" == "null" ]] || [[ "${CONTROL_NS}" == "" ]]; then + info "control_namespace not found" + else + # cleanup namespaceScope in Control namespace + cleanup_NamespaceScope $CONTROL_NS + # cleanup webhook + cleanup_webhook $CONTROL_NS "" + # cleanup secretshare + cleanup_secretshare $CONTROL_NS "" + # cleanup crossplane + cleanup_crossplane + # delete common-service-maps + ${OC} delete configmap common-service-maps -n kube-public + # delete namespace + ${OC} delete --ignore-not-found ns "$CONTROL_NS" --timeout=30s + if [ $? -ne 0 ] || [ $FORCE_DELETE -eq 1 ]; then + warning "Failed to delete namespace $CONTROL_NS, force deleting remaining resources..." + remove_all_finalizers $ns && success "Namespace $CONTROL_NS is deleted successfully." + fi - success "Control namespace: ${CONTROL_NS} is cleanup" + success "Control namespace: ${CONTROL_NS} is cleanup" + fi fi }