Skip to content

Commit 277ea2f

Browse files
Support parallel collection in default op mode
Signed-off-by: black-dragon74 <[email protected]>
1 parent f79b5b0 commit 277ea2f

File tree

1 file changed

+16
-49
lines changed

1 file changed

+16
-49
lines changed

collection-scripts/gather_main

Lines changed: 16 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,25 @@
11
#!/usr/bin/env bash
22

3-
export BASE_COLLECTION_PATH="must-gather"
4-
mkdir -p ${BASE_COLLECTION_PATH}
3+
procids=()
54

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

9-
# Source the utils
10-
# shellcheck disable=SC1091
11-
. utils.sh
9+
gather_clusterscoped_resources &
10+
procids+=($!)
1211

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

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

21-
# Call other gather scripts
22-
gather_namespaced_resources ${BASE_COLLECTION_PATH}
23-
gather_clusterscoped_resources ${BASE_COLLECTION_PATH}
24-
gather_noobaa_resources ${BASE_COLLECTION_PATH}
25-
gather_odf_client ${BASE_COLLECTION_PATH}
18+
gather_ceph_pod_logs &
19+
procids+=($!)
2620

27-
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)
28-
storageClusterPresent=$(oc get storagecluster -n "${namespace}" -o go-template='{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
29-
externalStorageClusterPresent=$(oc get storagecluster -n "${namespace}" -o go-template='{{range .items}}{{.spec.externalStorage.enable}}{{"\n"}}{{end}}')
30-
reconcileStrategy=$(oc get storagecluster -n "${namespace}" -o go-template='{{range .items}}{{.spec.multiCloudGateway.reconcileStrategy}}{{"\n"}}{{end}}')
31-
32-
if [ "${externalStorageClusterPresent}" = "true" ]; then
33-
dbglog "Collecting limited ceph logs since external cluster is present"
34-
gather_common_ceph_resources "${BASE_COLLECTION_PATH}"
35-
elif [ -z "${storageClusterPresent}" ]; then
36-
dbglog "Skipping ceph collection as Storage Cluster is not present"
37-
elif [ "${reconcileStrategy}" = "standalone" ]; then
38-
dbglog "Skipping ceph collection as this is a MCG only cluster"
39-
else
40-
dbglog "Collecting entire ceph logs"
41-
gather_ceph_resources ${BASE_COLLECTION_PATH}
21+
# Check if procid array has any values, if so, wait for them to finish
22+
if [ ${#procids[@]} -ne 0 ]; then
23+
echo "Waiting on collection scripts to finish."
24+
wait "${procids[@]}"
4225
fi
43-
44-
# Call post-uninstall.sh
45-
post-uninstall.sh
46-
47-
# timestamp for ending of the script
48-
END_TIME=$(date +%r)
49-
end=$(date +%s)
50-
totalTime=$((end - start))
51-
{
52-
printf "total time taken by collection was %s seconds \n" ${totalTime}
53-
printf "collection ended at: %s \n" "${END_TIME}"
54-
echo "deleting empty files"
55-
56-
} >>${BASE_COLLECTION_PATH}/gather-debug.log 2>&1
57-
find "${BASE_COLLECTION_PATH}" -empty -delete >>${BASE_COLLECTION_PATH}/gather-debug.log 2>&1
58-
exit 0

0 commit comments

Comments
 (0)