From 0c784da3d7a97689c378f99c423a608348b673e3 Mon Sep 17 00:00:00 2001 From: Kyl Bempah Date: Wed, 21 Oct 2020 15:39:35 -0400 Subject: [PATCH 1/8] Update uninstall.sh --- uninstall.sh | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index ef51392f3..671f11ea3 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -46,18 +46,40 @@ printf "\n" oc cluster-info | head -n 1 | awk '{print $NF}' printf "\n" -./clean-clusters.sh "$args" +if [ -z ${OCM_NAMESPACE+x} ]; +then + echo "OCM_NAMESPACE must be set" + exit 1 +else + echo "Cleaning up resources in namespace: $OCM_NAMESPACE" +fi +oc delete mch --all -n $OCM_NAMESPACE +## Delete all helm charts in given namespace +helm ls --namespace $OCM_NAMESPACE | cut -f 1 | tail -n +2 | xargs -n 1 helm delete --namespace $OCM_NAMESPACE +oc delete apiservice v1.admission.cluster.open-cluster-management.io v1beta1.webhook.certmanager.k8s.io v1.admission.cluster.open-cluster-management.io v1.admission.work.open-cluster-management.io +oc delete clusterimageset --all +oc delete configmap -n $OCM_NAMESPACE cert-manager-controller cert-manager-cainjector-leader-election cert-manager-cainjector-leader-election-core +oc delete consolelink acm-console-link +oc delete crd klusterletaddonconfigs.agent.open-cluster-management.io placementbindings.policy.open-cluster-management.io policies.policy.open-cluster-management.io userpreferences.console.open-cluster-management.io +oc delete mutatingwebhookconfiguration cert-manager-webhook-v1alpha1 +oc delete oauthclient multicloudingress +oc delete rolebinding -n kube-system cert-manager-webhook-webhook-authentication-reader +oc delete scc kui-proxy-scc +oc delete validatingwebhookconfiguration cert-manager-webhook-v1alpha1 +exit 0 + +#./clean-clusters.sh "$args" -kubectl delete -k multiclusterhub/ -echo "Sleeping for 200 seconds to allow resources to finalize ..." -sleep 200 +#kubectl delete -k multiclusterhub/ +#echo "Sleeping for 200 seconds to allow resources to finalize ..." +#sleep 200 -kubectl delete -k multicluster-hub-operator/ -./multicluster-hub-operator/uninstall.sh +#kubectl delete -k multicluster-hub-operator/ +#./multicluster-hub-operator/uninstall.sh -kubectl delete -k acm-operator/ -./acm-operator/uninstall.sh +#kubectl delete -k acm-operator/ +#./acm-operator/uninstall.sh -kubectl delete -k community-subscriptions/ +#kubectl delete -k community-subscriptions/ exit 0 From 928da4e88e1d4f91b24f61db5a6975eabb8c6eb5 Mon Sep 17 00:00:00 2001 From: Kyl-Bempah Date: Thu, 22 Oct 2020 10:36:49 -0400 Subject: [PATCH 2/8] Add namespace variable to uninstall --- uninstall.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/uninstall.sh b/uninstall.sh index 671f11ea3..a1d7fb220 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -5,6 +5,7 @@ KEEP_PROVIDERS=0 +OCM_NAMESPACE=open-cluster-management # save args to pass to called scripts args=("$@") From 7d04589dfbb8270a5b4eb9b31c8c91909337d27b Mon Sep 17 00:00:00 2001 From: Kyl-Bempah Date: Mon, 9 Nov 2020 16:54:05 -0500 Subject: [PATCH 3/8] Add debug info for uninstall --- uninstall.sh | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index a1d7fb220..1140ef485 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -6,6 +6,9 @@ KEEP_PROVIDERS=0 OCM_NAMESPACE=open-cluster-management +TOTAL_POD_COUNT_2X=55 +POLL_DURATION_21X=1500 + # save args to pass to called scripts args=("$@") @@ -47,6 +50,8 @@ printf "\n" oc cluster-info | head -n 1 | awk '{print $NF}' printf "\n" +./clean-clusters.sh "$args" + if [ -z ${OCM_NAMESPACE+x} ]; then echo "OCM_NAMESPACE must be set" @@ -69,8 +74,6 @@ oc delete scc kui-proxy-scc oc delete validatingwebhookconfiguration cert-manager-webhook-v1alpha1 exit 0 -#./clean-clusters.sh "$args" - #kubectl delete -k multiclusterhub/ #echo "Sleeping for 200 seconds to allow resources to finalize ..." #sleep 200 @@ -83,4 +86,40 @@ exit 0 #kubectl delete -k community-subscriptions/ +COMPLETE=1 +if [[ " $@ " =~ " --watch " ]]; then + if [[ $DEFAULT_SNAPSHOT =~ v{0,1}2\.[1-9][0-9]*\.[0-9]+.* ]]; then + echo "" + echo "#####" + #mch_status=`oc get multiclusterhub --all-namespaces` + acc=0 + while [[ $(oc get multiclusterhub --all-namespaces) && $acc -le $POLL_DURATION_21X ]]; do + curr_status=$(oc get multiclusterhub --all-namespaces -o json | jq -r '.items[].status.phase') 2> /dev/null + echo "Waited $acc/$POLL_DURATION_21X seconds for MCH to be deleted. Current Status: $curr_status" + if [[ "$DEBUG" == "true" ]]; then + echo "#####" + component_list=$(oc get multiclusterhub --all-namespaces -o json | jq -r '.items[].status.components') + printf "%-30s\t%-10s\t%-30s\t%-30s\n" "COMPONENT" "STATUS" "TYPE" "REASON" + for status_item in $(echo $component_list | jq -r 'keys | .[]'); do + component=$(echo $component_list | jq -r --arg ITEM_NAME "$status_item" '.[$ITEM_NAME]') + component_status="$(echo $component | jq -r '.status')"; + type="$(echo $component | jq -r '.type')"; + reason="$(echo $component | jq -r '.reason')"; + message="$(echo $component | jq -r '.message')"; + printf "%-30s\t%-10s\t%-30s\t%-30s\n" "$status_item" "$component_status" "$type" "$reason" + done + fi + echo "" + acc=$((acc+30)) + sleep 30 + done; + if [[ $(oc get multiclusterhub --all-namespaces) ]]; then + COMPLETE=1 + else + COMPLETE=0 + echo "MCH was not deleted after $acc seconds." + echo "" + fi + fi +fi exit 0 From 9aaf5bf1bc67345d458b1ce9f04a5c9b6bfeee0b Mon Sep 17 00:00:00 2001 From: Kyl Bempah Date: Mon, 16 Nov 2020 11:34:10 -0500 Subject: [PATCH 4/8] Fix completion message --- uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uninstall.sh b/uninstall.sh index 1140ef485..fc9ed2451 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -117,7 +117,7 @@ if [[ " $@ " =~ " --watch " ]]; then COMPLETE=1 else COMPLETE=0 - echo "MCH was not deleted after $acc seconds." + echo "MCH was deleted after $acc seconds." echo "" fi fi From aba67ed0ee28ad35b89085fa06cca5529061d64c Mon Sep 17 00:00:00 2001 From: Kyl Bempah Date: Thu, 19 Nov 2020 11:43:28 -0500 Subject: [PATCH 5/8] Strip to just mch deletion --- uninstall.sh | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index fc9ed2451..b20b4444f 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -50,7 +50,7 @@ printf "\n" oc cluster-info | head -n 1 | awk '{print $NF}' printf "\n" -./clean-clusters.sh "$args" +#./clean-clusters.sh "$args" if [ -z ${OCM_NAMESPACE+x} ]; then @@ -61,18 +61,17 @@ else fi oc delete mch --all -n $OCM_NAMESPACE ## Delete all helm charts in given namespace -helm ls --namespace $OCM_NAMESPACE | cut -f 1 | tail -n +2 | xargs -n 1 helm delete --namespace $OCM_NAMESPACE -oc delete apiservice v1.admission.cluster.open-cluster-management.io v1beta1.webhook.certmanager.k8s.io v1.admission.cluster.open-cluster-management.io v1.admission.work.open-cluster-management.io -oc delete clusterimageset --all -oc delete configmap -n $OCM_NAMESPACE cert-manager-controller cert-manager-cainjector-leader-election cert-manager-cainjector-leader-election-core -oc delete consolelink acm-console-link -oc delete crd klusterletaddonconfigs.agent.open-cluster-management.io placementbindings.policy.open-cluster-management.io policies.policy.open-cluster-management.io userpreferences.console.open-cluster-management.io -oc delete mutatingwebhookconfiguration cert-manager-webhook-v1alpha1 -oc delete oauthclient multicloudingress -oc delete rolebinding -n kube-system cert-manager-webhook-webhook-authentication-reader -oc delete scc kui-proxy-scc -oc delete validatingwebhookconfiguration cert-manager-webhook-v1alpha1 -exit 0 +#helm ls --namespace $OCM_NAMESPACE | cut -f 1 | tail -n +2 | xargs -n 1 helm delete --namespace $OCM_NAMESPACE +#oc delete apiservice v1.admission.cluster.open-cluster-management.io v1beta1.webhook.certmanager.k8s.io v1.admission.cluster.open-cluster-management.io v1.admission.work.open-cluster-management.io +#oc delete clusterimageset --all +#oc delete configmap -n $OCM_NAMESPACE cert-manager-controller cert-manager-cainjector-leader-election cert-manager-cainjector-leader-election-core +#oc delete consolelink acm-console-link +#oc delete crd klusterletaddonconfigs.agent.open-cluster-management.io placementbindings.policy.open-cluster-management.io policies.policy.open-cluster-management.io userpreferences.console.open-cluster-management.io +#oc delete mutatingwebhookconfiguration cert-manager-webhook-v1alpha1 +#oc delete oauthclient multicloudingress +#oc delete rolebinding -n kube-system cert-manager-webhook-webhook-authentication-reader +#oc delete scc kui-proxy-scc +#oc delete validatingwebhookconfiguration cert-manager-webhook-v1alpha1 #kubectl delete -k multiclusterhub/ #echo "Sleeping for 200 seconds to allow resources to finalize ..." From 5324ece749f83bf81aa69d7eccf26ed3378a7c98 Mon Sep 17 00:00:00 2001 From: Kyl Bempah Date: Fri, 20 Nov 2020 12:27:27 -0500 Subject: [PATCH 6/8] Add mco to uninstall --- uninstall.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/uninstall.sh b/uninstall.sh index b20b4444f..1b1702042 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -59,6 +59,46 @@ then else echo "Cleaning up resources in namespace: $OCM_NAMESPACE" fi + +oc delete mco --all -n $OCM_NAMESPACE + +COMPLETE=1 +if [[ " $@ " =~ " --watch " ]]; then + if [[ $DEFAULT_SNAPSHOT =~ v{0,1}2\.[1-9][0-9]*\.[0-9]+.* ]]; then + echo "" + echo "#####" + #mch_status=`oc get multiclusterhub --all-namespaces` + acc=0 + while [[ $(oc get multiclusterobservability --all-namespaces) && $acc -le $POLL_DURATION_21X ]]; do + curr_status=$(oc get multiclusterhub --all-namespaces -o json | jq -r '.items[].status.phase') 2> /dev/null + echo "Waited $acc/$POLL_DURATION_21X seconds for MCH to be deleted. Current Status: $curr_status" + if [[ "$DEBUG" == "true" ]]; then + echo "#####" + component_list=$(oc get multiclusterobservability --all-namespaces -o json | jq -r '.items[].status.components') + printf "%-30s\t%-10s\t%-30s\t%-30s\n" "COMPONENT" "STATUS" "TYPE" "REASON" + for status_item in $(echo $component_list | jq -r 'keys | .[]'); do + component=$(echo $component_list | jq -r --arg ITEM_NAME "$status_item" '.[$ITEM_NAME]') + component_status="$(echo $component | jq -r '.status')"; + type="$(echo $component | jq -r '.type')"; + reason="$(echo $component | jq -r '.reason')"; + message="$(echo $component | jq -r '.message')"; + printf "%-30s\t%-10s\t%-30s\t%-30s\n" "$status_item" "$component_status" "$type" "$reason" + done + fi + echo "" + acc=$((acc+30)) + sleep 30 + done; + if [[ $(oc get multiclusterhub --all-namespaces) ]]; then + COMPLETE=1 + else + COMPLETE=0 + echo "MCH was deleted after $acc seconds." + echo "" + fi + fi +fi + oc delete mch --all -n $OCM_NAMESPACE ## Delete all helm charts in given namespace #helm ls --namespace $OCM_NAMESPACE | cut -f 1 | tail -n +2 | xargs -n 1 helm delete --namespace $OCM_NAMESPACE From 60a440bc9f41ded13a26e6a009f43ae18965ee5a Mon Sep 17 00:00:00 2001 From: Kyl Bempah Date: Fri, 20 Nov 2020 12:31:47 -0500 Subject: [PATCH 7/8] Fix mco watch check --- uninstall.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index 1b1702042..9321cab34 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -89,11 +89,11 @@ if [[ " $@ " =~ " --watch " ]]; then acc=$((acc+30)) sleep 30 done; - if [[ $(oc get multiclusterhub --all-namespaces) ]]; then + if [[ $(oc get multiclusterobservability --all-namespaces) ]]; then COMPLETE=1 else COMPLETE=0 - echo "MCH was deleted after $acc seconds." + echo "MCO was deleted after $acc seconds." echo "" fi fi From a9f280a04736cdecd968e56b84c8e77560ed0aa3 Mon Sep 17 00:00:00 2001 From: Kyl Bempah Date: Fri, 20 Nov 2020 13:04:35 -0500 Subject: [PATCH 8/8] Updating referenced --- uninstall.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uninstall.sh b/uninstall.sh index 9321cab34..0aedaf789 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -70,8 +70,8 @@ if [[ " $@ " =~ " --watch " ]]; then #mch_status=`oc get multiclusterhub --all-namespaces` acc=0 while [[ $(oc get multiclusterobservability --all-namespaces) && $acc -le $POLL_DURATION_21X ]]; do - curr_status=$(oc get multiclusterhub --all-namespaces -o json | jq -r '.items[].status.phase') 2> /dev/null - echo "Waited $acc/$POLL_DURATION_21X seconds for MCH to be deleted. Current Status: $curr_status" + curr_status=$(oc get multiclusterobservability --all-namespaces -o json | jq -r '.items[].status.phase') 2> /dev/null + echo "Waited $acc/$POLL_DURATION_21X seconds for MCO to be deleted. Current Status: $curr_status" if [[ "$DEBUG" == "true" ]]; then echo "#####" component_list=$(oc get multiclusterobservability --all-namespaces -o json | jq -r '.items[].status.components')