|
1 | 1 | #!/usr/bin/env bash
|
2 | 2 |
|
3 |
| -export BASE_COLLECTION_PATH="must-gather" |
4 |
| -mkdir -p ${BASE_COLLECTION_PATH} |
| 3 | +procids=() |
5 | 4 |
|
6 |
| -# Command line argument |
7 |
| -export SINCE_TIME=$1 |
| 5 | +# Call other gather scripts in parallel |
| 6 | +gather_namespaced_resources & |
| 7 | +procids+=($!) |
8 | 8 |
|
9 |
| -# Source the utils |
10 |
| -# shellcheck disable=SC1091 |
11 |
| -. utils.sh |
| 9 | +gather_clusterscoped_resources & |
| 10 | +procids+=($!) |
12 | 11 |
|
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+=($!) |
17 | 14 |
|
18 |
| -# Call pre-install.sh, see commit msg |
19 |
| -pre-install.sh ${BASE_COLLECTION_PATH} |
| 15 | +gather_odf_client & |
| 16 | +procids+=($!) |
20 | 17 |
|
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+=($!) |
26 | 20 |
|
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[@]}" |
42 | 25 | 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