Skip to content

Commit

Permalink
Support parallel collection in default op mode
Browse files Browse the repository at this point in the history
Signed-off-by: black-dragon74 <[email protected]>
  • Loading branch information
black-dragon74 committed Dec 19, 2023
1 parent f79b5b0 commit 277ea2f
Showing 1 changed file with 16 additions and 49 deletions.
65 changes: 16 additions & 49 deletions collection-scripts/gather_main
Original file line number Diff line number Diff line change
@@ -1,58 +1,25 @@
#!/usr/bin/env bash

export BASE_COLLECTION_PATH="must-gather"
mkdir -p ${BASE_COLLECTION_PATH}
procids=()

# Command line argument
export SINCE_TIME=$1
# Call other gather scripts in parallel
gather_namespaced_resources &
procids+=($!)

# Source the utils
# shellcheck disable=SC1091
. utils.sh
gather_clusterscoped_resources &
procids+=($!)

# timestamp for starting of the script
START_TIME=$(date +%r)
start=$(date +%s)
dbglog "collection started at: ${START_TIME}"
gather_noobaa_resources &
procids+=($!)

# Call pre-install.sh, see commit msg
pre-install.sh ${BASE_COLLECTION_PATH}
gather_odf_client &
procids+=($!)

# Call other gather scripts
gather_namespaced_resources ${BASE_COLLECTION_PATH}
gather_clusterscoped_resources ${BASE_COLLECTION_PATH}
gather_noobaa_resources ${BASE_COLLECTION_PATH}
gather_odf_client ${BASE_COLLECTION_PATH}
gather_ceph_pod_logs &
procids+=($!)

namespace=$(oc get deploy --all-namespaces -o go-template --template='{{range .items}}{{if .metadata.labels}}{{printf "%s %v" .metadata.namespace (index .metadata.labels "olm.owner")}} {{printf "\n"}}{{end}}{{end}}' | grep ocs-operator | awk '{print $1}' | uniq)
storageClusterPresent=$(oc get storagecluster -n "${namespace}" -o go-template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
externalStorageClusterPresent=$(oc get storagecluster -n "${namespace}" -o go-template='{{range .items}}{{.spec.externalStorage.enable}}{{"\n"}}{{end}}')
reconcileStrategy=$(oc get storagecluster -n "${namespace}" -o go-template='{{range .items}}{{.spec.multiCloudGateway.reconcileStrategy}}{{"\n"}}{{end}}')

if [ "${externalStorageClusterPresent}" = "true" ]; then
dbglog "Collecting limited ceph logs since external cluster is present"
gather_common_ceph_resources "${BASE_COLLECTION_PATH}"
elif [ -z "${storageClusterPresent}" ]; then
dbglog "Skipping ceph collection as Storage Cluster is not present"
elif [ "${reconcileStrategy}" = "standalone" ]; then
dbglog "Skipping ceph collection as this is a MCG only cluster"
else
dbglog "Collecting entire ceph logs"
gather_ceph_resources ${BASE_COLLECTION_PATH}
# Check if procid array has any values, if so, wait for them to finish
if [ ${#procids[@]} -ne 0 ]; then
echo "Waiting on collection scripts to finish."
wait "${procids[@]}"
fi

# Call post-uninstall.sh
post-uninstall.sh

# timestamp for ending of the script
END_TIME=$(date +%r)
end=$(date +%s)
totalTime=$((end - start))
{
printf "total time taken by collection was %s seconds \n" ${totalTime}
printf "collection ended at: %s \n" "${END_TIME}"
echo "deleting empty files"

} >>${BASE_COLLECTION_PATH}/gather-debug.log 2>&1
find "${BASE_COLLECTION_PATH}" -empty -delete >>${BASE_COLLECTION_PATH}/gather-debug.log 2>&1
exit 0

0 comments on commit 277ea2f

Please sign in to comment.