Skip to content

Commit

Permalink
Add debug info for uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyl-Bempah committed Nov 9, 2020
1 parent 928da4e commit 7d04589
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=("$@")
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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

0 comments on commit 7d04589

Please sign in to comment.