From eb17c5f2b4e7fcaf877952330f3d7e78eb7fb82c Mon Sep 17 00:00:00 2001 From: saberhamidi Date: Tue, 20 Feb 2024 17:04:12 +0000 Subject: [PATCH 1/2] apicops must gather added --- generate_postmortem.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/generate_postmortem.sh b/generate_postmortem.sh index 47749bf..3ab11b6 100755 --- a/generate_postmortem.sh +++ b/generate_postmortem.sh @@ -1107,6 +1107,39 @@ for NAMESPACE in $NAMESPACE_LIST; do $CURRENT_PATH/edb_mustgather.sh $NAMESPACE $K8S_NAMESPACES_EDB &> "${K8S_NAMESPACES_EDB}/edb-collect.log" fi + #grab apicops mustgather + MGMT=$(kubectl get mgmt -n $NAMESPACE 2>&1) + if [[ $MGMT != *"No resources found"* ]]; then + + which apicops &> /dev/null + if [[ $? -eq 0 ]]; then + APICOPS="apicops" + else + if [[ ! -e /tmp/apicops-v10-linux ]]; then + echo -e "Downloading apicops......" + curl -L -o /tmp/apicops-v10-linux https://github.com/ibm-apiconnect/apicops/releases/latest/download/apicops-v10-linux + if [[ ! -e /tmp/apicops-v10-linux ]]; then + echo -e "Warning: Failed to download the apicops cli. Skipping to collect apicops debuggings commands output. Please download the latest release of apicops manually before running the postmortem script. commands: curl -LO https://github.com/ibm-apiconnect/apicops/releases/latest/download/apicops-v10-linux" + else + chmod +x /tmp/apicops-v10-linux + APICOPS="/tmp/apicops-v10-linux" + fi + else + APICOPS="/tmp/apicops-v10-linux" + fi + fi + + if [ -v APICOPS ]; then + K8S_NAMESPACES_APICOPS_DATA="${K8S_NAMESPACES_SPECIFIC}/apicops" + mkdir -p $K8S_NAMESPACES_APICOPS_DATA + + #List of apicops commands to be run for mustgather + $APICOPS iss -n $NAMESPACE > "${K8S_NAMESPACES_APICOPS_DATA}/iss.out" + $APICOPS debug:info -n $NAMESPACE > "${K8S_NAMESPACES_APICOPS_DATA}/debug-info.out" + + fi + fi + #grab daemonset data OUTPUT=`$KUBECTL get daemonset -n $NAMESPACE 2>/dev/null` if [[ $? -eq 0 && ${#OUTPUT} -gt 0 ]]; then @@ -1574,6 +1607,8 @@ for NAMESPACE in $NAMESPACE_LIST; do echo "$OUTPUT1" >"${PORTAL_DIAGNOSTIC_DATA}/list_sites-platform.out" OUTPUT1=`$KUBECTL exec -n $NAMESPACE -c $container $pod -- bash -ic "/opt/ibm/bin/list_sites -d" 2>"/dev/null"` echo "$OUTPUT1" >"${PORTAL_DIAGNOSTIC_DATA}/list_sites-database.out" + OUTPUT1=`$KUBECTL exec -n $NAMESPACE -c $container $pod -- bash -ic "/opt/ibm/bin/check_site -a" 2>"/dev/null"` + echo "$OUTPUT1" >"${PORTAL_DIAGNOSTIC_DATA}/check_site-all.out" OUTPUT1=`$KUBECTL exec -n $NAMESPACE -c $container $pod -- bash -ic "/opt/ibm/bin/list_platforms" 2>"/dev/null"` echo "$OUTPUT1" >"${PORTAL_DIAGNOSTIC_DATA}/list_platforms.out" OUTPUT1=`$KUBECTL exec -n $NAMESPACE -c $container $pod -- bash -ic "ls -lRAi --author --full-time" 2>"/dev/null"` From c4da820eddec6d18345b7a451e623964072336ac Mon Sep 17 00:00:00 2001 From: saberhamidi Date: Tue, 20 Feb 2024 18:11:08 +0000 Subject: [PATCH 2/2] added prompt for downloading apicops --- generate_postmortem.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/generate_postmortem.sh b/generate_postmortem.sh index 3ab11b6..6218f21 100755 --- a/generate_postmortem.sh +++ b/generate_postmortem.sh @@ -1116,14 +1116,23 @@ for NAMESPACE in $NAMESPACE_LIST; do APICOPS="apicops" else if [[ ! -e /tmp/apicops-v10-linux ]]; then - echo -e "Downloading apicops......" - curl -L -o /tmp/apicops-v10-linux https://github.com/ibm-apiconnect/apicops/releases/latest/download/apicops-v10-linux - if [[ ! -e /tmp/apicops-v10-linux ]]; then - echo -e "Warning: Failed to download the apicops cli. Skipping to collect apicops debuggings commands output. Please download the latest release of apicops manually before running the postmortem script. commands: curl -LO https://github.com/ibm-apiconnect/apicops/releases/latest/download/apicops-v10-linux" - else - chmod +x /tmp/apicops-v10-linux - APICOPS="/tmp/apicops-v10-linux" - fi + echo -e "apicops cli not found!" + read -p "Download and Install apicops cli (y/n)? " yn + case $yn in + [Yy]* ) + echo -e "Downloading apicops......" + curl -L -o /tmp/apicops-v10-linux https://github.com/ibm-apiconnect/apicops/releases/latest/download/apicops-v10-linux + if [[ ! -e /tmp/apicops-v10-linux ]]; then + echo -e "Warning: Failed to download the apicops cli. Skipping to collect apicops mustgather. Please download the latest release of apicops manually before running the postmortem script. commands: curl -LO https://github.com/ibm-apiconnect/apicops/releases/latest/download/apicops-v10-linux" + else + chmod +x /tmp/apicops-v10-linux + APICOPS="/tmp/apicops-v10-linux" + fi + ;; + [Nn]* ) + echo -e "Skipping to collect apicops mustgather" + ;; + esac else APICOPS="/tmp/apicops-v10-linux" fi