From 626ec18519b0877f73bccf2d56ec7b91b204e35c Mon Sep 17 00:00:00 2001 From: William McEnery Date: Thu, 16 Nov 2023 16:38:11 +0000 Subject: [PATCH 1/3] Make kubectl cnp a requirement, check for edb operator namespace. --- README.md | 2 +- edb_mustgather.sh | 25 ++++++++++--------------- generate_postmortem.sh | 14 +++++++++++--- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 6ad0d8e..4b1f77e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ With the move to API Connect v10, **helm** is not longer used as part of the dep - While the postmortem collection script is running, it is expected that the CPU and I/O load for the APIC deployment and its host cluster/VM will be increased. ## Pre-Requisite -- If EDB is deployed you will need the kubectl-cnp [plugin](https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/cnp-plugin) to gather appropriate EDB logs +- If EDB is deployed you will need the kubectl-cnp [plugin](https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin) to gather appropriate EDB logs ## Deployment Instructions ### OVA diff --git a/edb_mustgather.sh b/edb_mustgather.sh index 3330a9d..b390e09 100755 --- a/edb_mustgather.sh +++ b/edb_mustgather.sh @@ -18,14 +18,12 @@ fi EDB_CLUSTER_NAMESPACE=$1 LOG_PATH=$2 -CNP_INSTALLED=false if which kubectl-cnp >/dev/null; then echo kubectl-cnp plugin found - CNP_INSTALLED=true else - echo kubectl-cnp plugin not found, please install it from here https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/cnp-plugin - CNP_INSTALLED=false + echo kubectl-cnp plugin not found, please install it from here https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin + exit 1 fi if [ -z "$1" ] || [ -z "$2" ] @@ -44,7 +42,7 @@ if [ "$ARCHITECTURE" = 's390x' ]; then EDB_OP_NAMESPACE='ibm-common-services' PG_OP=$($KUBECTL get po -n ${EDB_OP_NAMESPACE} -o=custom-columns=NAME:.metadata.name | grep postgresql-operator-controller-manager) else - EDB_OP_NAMESPACE=$EDB_CLUSTER_NAMESPACE + EDB_OP_NAMESPACE=$($KUBECTL get po -A | grep edb-operator | awk -F ' ' '{print $1}' | head -n 1) PG_OP=$($KUBECTL get po -n ${EDB_OP_NAMESPACE} -o=custom-columns=NAME:.metadata.name | grep edb-operator) fi @@ -78,9 +76,8 @@ mkdir ${CLUSTER_BACKUPS} mkdir ${CLUSTER_BACKUPS}/${EDB_CLUSTER_NAME} function gatherEdbOperatorData() { - if [ "$CNP_INSTALLED" = true ]; then - $KUBECTL cnp report operator --logs -n ${EDB_OP_NAMESPACE} -f ${SPECIFIC_NS_EDB_OP}/operator-report.zip - fi + $KUBECTL cnp report operator --logs -n ${EDB_OP_NAMESPACE} -f ${SPECIFIC_NS_EDB_OP}/operator-report.zip + for pod in $PG_OP do mkdir ${OPERATOR_PODS}/${pod} @@ -92,10 +89,9 @@ function gatherEdbOperatorData() { } function gatherClusterData() { - if [ "$CNP_INSTALLED" = true ]; then - $KUBECTL cnp status ${EDB_CLUSTER_NAME} -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/status.txt - $KUBECTL cnp status ${EDB_CLUSTER_NAME} --verbose -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/status-verbose.txt - fi + $KUBECTL cnp status ${EDB_CLUSTER_NAME} -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/status.txt + $KUBECTL cnp status ${EDB_CLUSTER_NAME} --verbose -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/status-verbose.txt + $KUBECTL get cluster -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/info.txt $KUBECTL get cluster -o yaml -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/cluster.yaml $KUBECTL describe cluster -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER}/${EDB_CLUSTER_NAME}/describe.txt @@ -103,9 +99,8 @@ function gatherClusterData() { } function gatherEDBPodData() { - if [ "$CNP_INSTALLED" = true ]; then - $KUBECTL cnp report cluster ${EDB_CLUSTER_NAME} --logs -n ${EDB_CLUSTER_NAMESPACE} -f ${SPECIFIC_NS_CLUSTER}/cluster-report.zip - fi + $KUBECTL cnp report cluster ${EDB_CLUSTER_NAME} --logs -n ${EDB_CLUSTER_NAMESPACE} -f ${SPECIFIC_NS_CLUSTER}/cluster-report.zip + $KUBECTL get pod -l k8s.enterprisedb.io/cluster=${EDB_CLUSTER_NAME} -L role -n ${EDB_CLUSTER_NAMESPACE} > ${CLUSTER_PODS}/pods.txt for pod in ${EDB_POD_NAMES}; do mkdir ${CLUSTER_PODS}/${pod} diff --git a/generate_postmortem.sh b/generate_postmortem.sh index 915a922..c2a3a4c 100755 --- a/generate_postmortem.sh +++ b/generate_postmortem.sh @@ -177,6 +177,14 @@ for switch in $@; do ;; *"--collect-edb"*) COLLECT_EDB=1 + + if which kubectl-cnp >/dev/null; then + echo kubectl-cnp plugin found + else + echo -e "kubectl-cnp plugin not found, please install it from here https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin. Exiting..." + exit 1 + fi + SCRIPT_LOCATION="`pwd`/edb_mustgather.sh" if [[ ! -f $SCRIPT_LOCATION ]]; then echo -e "Unable to locate script [edb_mustgather.sh] in current directory. Download from GitHub repository. Exiting..." @@ -420,13 +428,13 @@ if [[ $IS_OVA -eq 1 ]]; then #Getting subsystem meta file content cat /var/lib/apiconnect-subsystem/meta.yml 1>"${OVA_LIBFOLDER}/subsystem-meta.out" 2>/dev/null - #Getting side-registry recursive file listing + #Getting side-registry recursive file listing find /var/lib/apiconnect/side-registry/ 1>"${OVA_LIBFOLDER}/side-registry.out" 2>/dev/null - #Getting appliance-control-plane recursive file listing + #Getting appliance-control-plane recursive file listing find /usr/local/lib/appliance-control-plane/ 1>"${OVA_USRLOCALLIBFOLDER}/appliance-control-plane.out" 2>/dev/null - #Getting appliance-side-registry recursive file listing + #Getting appliance-side-registry recursive file listing find /usr/local/lib/appliance-side-registry/ 1>"${OVA_USRLOCALLIBFOLDER}/appliance-side-registry.out" 2>/dev/null fi From 9006127f821e848213ab421408b94584bda58b64 Mon Sep 17 00:00:00 2001 From: William McEnery Date: Thu, 23 Nov 2023 16:30:11 +0000 Subject: [PATCH 2/3] Make kubectl cnp a requirement, check for edb operator namespace. --- edb_mustgather.sh | 7 +++---- generate_postmortem.sh | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/edb_mustgather.sh b/edb_mustgather.sh index b390e09..4ab5b5e 100755 --- a/edb_mustgather.sh +++ b/edb_mustgather.sh @@ -42,8 +42,8 @@ if [ "$ARCHITECTURE" = 's390x' ]; then EDB_OP_NAMESPACE='ibm-common-services' PG_OP=$($KUBECTL get po -n ${EDB_OP_NAMESPACE} -o=custom-columns=NAME:.metadata.name | grep postgresql-operator-controller-manager) else - EDB_OP_NAMESPACE=$($KUBECTL get po -A | grep edb-operator | awk -F ' ' '{print $1}' | head -n 1) - PG_OP=$($KUBECTL get po -n ${EDB_OP_NAMESPACE} -o=custom-columns=NAME:.metadata.name | grep edb-operator) + EDB_OP_NAMESPACE=$EDB_CLUSTER_NAMESPACE + PG_OP=$($KUBECTL get po -n ${EDB_OP_NAMESPACE} -o=custom-columns=NAME:.metadata.name | grep -e edb-operator -e postgresql-operator-controller-manager) fi EDB_CLUSTER_NAME=$($KUBECTL get cluster -n ${EDB_CLUSTER_NAMESPACE} -o=jsonpath='{.items[0].metadata.name}') @@ -124,8 +124,7 @@ function gatherEDBBackupData() { if [[ -z "$PG_OP" ]]; then - echo "failed to find the edb operator in the ${EDB_OP_NAMESPACE} namespace" - exit 1 + echo "failed to find the edb operator in the ${EDB_OP_NAMESPACE} namespace, could be in a different namespace" else gatherEdbOperatorData fi diff --git a/generate_postmortem.sh b/generate_postmortem.sh index c2a3a4c..bb1c32b 100755 --- a/generate_postmortem.sh +++ b/generate_postmortem.sh @@ -932,7 +932,7 @@ for NAMESPACE in $NAMESPACE_LIST; do #grab cluster configuration, equivalent to "apiconnect-up.yml" which now resides in cluster - CLUSTER_LIST=(apic AnalyticsBackups AnalyticsClusters AnalyticsRestores APIConnectClusters DataPowerServices DataPowerMonitors EventEndpointManager EventGatewayClusters GatewayClusters ManagementBackups ManagementClusters ManagementDBUpgrades ManagementRestores NatsClusters NatsServiceRoles NatsStreamingClusters PGClusters PGPolicies PGReplicas PGTasks PortalBackups PortalClusters PortalRestores PortalSecretRotations) + CLUSTER_LIST=(apic AnalyticsBackups AnalyticsClusters AnalyticsRestores APIConnectClusters DataPowerServices DataPowerMonitors EventEndpointManager EventGatewayClusters GatewayClusters ManagementBackups ManagementClusters ManagementDBUpgrades ManagementRestores NatsClusters NatsServiceRoles NatsStreamingClusters PGClusters PGPolicies PGReplicas PGTasks PortalBackups PortalClusters PortalRestores PortalSecretRotations backups clusters poolers scheduledbackups) for cluster in ${CLUSTER_LIST[@]}; do OUTPUT=`$KUBECTL get -n $NAMESPACE $cluster 2>/dev/null` if [[ $? -eq 0 && ${#OUTPUT} -gt 0 ]]; then From 30e6c32dc917510f71fd7fbbf85bac8eaf801349 Mon Sep 17 00:00:00 2001 From: William McEnery Date: Thu, 30 Nov 2023 17:55:01 +0000 Subject: [PATCH 3/3] Make kubectl cnp a requirement, check for edb operator namespace. --- edb_mustgather.sh | 4 ++-- generate_postmortem.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/edb_mustgather.sh b/edb_mustgather.sh index 4ab5b5e..2810e33 100755 --- a/edb_mustgather.sh +++ b/edb_mustgather.sh @@ -10,7 +10,7 @@ if [[ $? -eq 0 ]]; then else which kubectl &> /dev/null if [[ $? -ne 0 ]]; then - echo "Unable to locate the command [kubectl] nor [oc] in the path. Either install or add it to the path. EXITING..." + echo "Unable to locate the command [kubectl] nor [oc] in the path. Either install or add it to your PATH. EXITING..." exit 1 fi KUBECTL="kubectl" @@ -22,7 +22,7 @@ LOG_PATH=$2 if which kubectl-cnp >/dev/null; then echo kubectl-cnp plugin found else - echo kubectl-cnp plugin not found, please install it from here https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin + echo kubectl-cnp plugin not found, please install it and add it to your PATH, see https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin exit 1 fi diff --git a/generate_postmortem.sh b/generate_postmortem.sh index bb1c32b..82562f9 100755 --- a/generate_postmortem.sh +++ b/generate_postmortem.sh @@ -181,7 +181,7 @@ for switch in $@; do if which kubectl-cnp >/dev/null; then echo kubectl-cnp plugin found else - echo -e "kubectl-cnp plugin not found, please install it from here https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin. Exiting..." + echo -e "kubectl-cnp plugin not found, please install it and add it to your PATH, see https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin. Exiting..." exit 1 fi