Skip to content

Commit

Permalink
Add new flag to collect minimal resources
Browse files Browse the repository at this point in the history
Creating a flag to limit data collection to only major CRDs and CSVs,
reducing time taken and log clutter.

Signed-off-by: Sheetal Pamecha <[email protected]>
  • Loading branch information
Sheetalpamecha committed Nov 6, 2024
1 parent 9713e49 commit 0b5cc18
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
13 changes: 13 additions & 0 deletions collection-scripts/gather
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespaced=false
clusterscoped=false
help=false
default=true
minimal_crds=false

# Store PIDs of all the subprocesses
pids=()
Expand Down Expand Up @@ -57,6 +58,11 @@ while [[ $# -gt 0 ]]; do
default=false
shift
;;
--minimal-crds)
minimal_crds=true
default=false
shift
;;
-h | --help)
help=true
default=false
Expand Down Expand Up @@ -93,6 +99,7 @@ Options:
-cl, --ceph-logs Collect ceph daemon, kernel, journal logs and crash reports
-ns, --namespaced Collect namespaced resources
-cs, --clusterscoped Collect clusterscoped resources
--minimal-crds Collect only relevant CRDs and CSVs
-h, --help Print this help message
Description:
Expand Down Expand Up @@ -197,6 +204,12 @@ if [ "$clusterscoped" == true ] && [ "$odf" == false ]; then
pids+=($!)
fi

if [ "$minimal_crds" == true ] && [ "$odf" == false ]; then
echo "Collect minimal resource files..."
gather_minimal_resources ${BASE_COLLECTION_PATH} &
pids+=($!)
fi

# Preserve the functionality to accept and forward other args
# This is unused as of now but is there, just in case :)
if [ $# -gt 0 ]; then
Expand Down
31 changes: 31 additions & 0 deletions collection-scripts/gather_minimal_resources
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

# Expect base collection path as an exported variable
# If it is not defined, use PWD instead
BASE_COLLECTION_PATH=${BASE_COLLECTION_PATH:-"$(pwd)"}

MINIMAL_COLLECTION_PATH="${BASE_COLLECTION_PATH}/minimal_resources"

# Create directories for minimal resources collection
mkdir -p "${MINIMAL_COLLECTION_PATH}/oc_output"

# Define minimal resources
minimal_resources=()
minimal_resources+=(cephclusters)
minimal_resources+=(cephblockpools)
minimal_resources+=(cephfilesystems)
minimal_resources+=(csv)
minimal_resources+=(sc)

# Collect resources except for storageclusters
for resource in "${minimal_resources[@]}"; do
dbglog "collecting dump ${resource}"
{ oc adm inspect --dest-dir="${MINIMAL_COLLECTION_PATH}" --all-namespaces ${LOG_FILTER_ARGS:+"${LOG_FILTER_ARGS}"} "${resource}" 2>&1; } | dbglog
done

# Special handling for storageclusters
dbglog "Collecting storageclusters"
{ oc get storageclusters --all-namespaces -o yaml; } > "${MINIMAL_COLLECTION_PATH}/oc_output/storageclusters.yaml" 2>&1

# Final message indicating completion
dbglog "Minimal resources collection completed."

0 comments on commit 0b5cc18

Please sign in to comment.