Skip to content

Commit

Permalink
Merge pull request #109 from ibm-apiconnect/wmce-8831
Browse files Browse the repository at this point in the history
Check for EDB operator namespace.
  • Loading branch information
WilliamMcEnery authored Dec 1, 2023
2 parents 59d4aae + 30e6c32 commit 65d485d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 12 additions & 18 deletions edb_mustgather.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,20 @@ 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"
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 and add it to your PATH, see https://www.enterprisedb.com/docs/postgres_for_kubernetes/latest/kubectl-plugin
exit 1
fi

if [ -z "$1" ] || [ -z "$2" ]
Expand All @@ -45,7 +43,7 @@ if [ "$ARCHITECTURE" = 's390x' ]; then
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
PG_OP=$($KUBECTL get po -n ${EDB_OP_NAMESPACE} -o=custom-columns=NAME:.metadata.name | grep edb-operator)
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}')
Expand Down Expand Up @@ -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}
Expand All @@ -92,20 +89,18 @@ 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

}

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}
Expand All @@ -129,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
Expand Down
16 changes: 12 additions & 4 deletions generate_postmortem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 and add it to your PATH, see 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..."
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -924,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
Expand Down

0 comments on commit 65d485d

Please sign in to comment.