Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing latest changes from main for odf-must-gather #126

Merged
merged 22 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0a2d57b
collect csidriver details for odf-client
yati1998 Feb 21, 2024
92b9fb9
Merge pull request #111 from yati1998/clusterscope
openshift-merge-bot[bot] Feb 21, 2024
f86bbe4
Add arg for collecting ODF logs
black-dragon74 Feb 21, 2024
65eeda2
Rename arg `-p` to `-pc`
black-dragon74 Feb 21, 2024
768e874
Update help text for the new arg
black-dragon74 Feb 21, 2024
448c91d
Update help text for ODF arg
black-dragon74 Feb 21, 2024
918b992
Merge pull request #112 from black-dragon74/add-odf-arg
openshift-merge-bot[bot] Feb 21, 2024
ae7ab3a
Merge pull request #113 from black-dragon74/rename-provider-arg
openshift-merge-bot[bot] Feb 21, 2024
3517902
Fix Readme file
OdedViner Feb 21, 2024
5b473b9
fix code
OdedViner Feb 21, 2024
3be2619
fix annotations
OdedViner Feb 21, 2024
82178cc
No need to call pre-install script for help flag
OdedViner Feb 21, 2024
a6e0c0b
fix code
OdedViner Feb 21, 2024
6572870
fix code
OdedViner Feb 21, 2024
254b89b
change image name
OdedViner Feb 21, 2024
65ade05
Merge pull request #119 from OdedViner/fix_help_flag
openshift-merge-bot[bot] Feb 21, 2024
7fa6d2e
Merge pull request #115 from OdedViner/fix_readme
openshift-merge-bot[bot] Feb 28, 2024
7c5f94d
Fix helptext formatting
black-dragon74 Feb 29, 2024
0fc5dfd
Merge pull request #122 from black-dragon74/fix-help-format
openshift-merge-bot[bot] Feb 29, 2024
831cfa9
update readme to include correct flag
yati1998 Feb 29, 2024
29f5517
Merge pull request #123 from yati1998/Readme
openshift-merge-bot[bot] Feb 29, 2024
4493297
collect resources for openshift-storage-extended ns
yati1998 Mar 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ oc adm must-gather --image=registry.redhat.io/odf4/odf-must-gather-rhel9:v4.13 -
List of arguments that can be passed to the odf-must-gather are:
```
-d, --dr Collect DR logs
-p, --provider Collect logs for provider/consumer cluster
-pc, --provider Collect openshift-storage-client logs from a provider/consumer cluster
-n, --nooba Collect nooba logs
-c, --ceph Collect ceph commands and pod logs
-cl, --ceph-logs Collect ceph daemon, kernel, journal logs and crash reports
Expand All @@ -33,13 +33,13 @@ from your cluster. This might take longer on some environments.

Note: Provide each arg separately and do not chain them like:
```
$ /usr/bin/gather -dpnc # Wrong
$ /usr/bin/gather -d -p -n -c # Correct
$ oc adm must-gather --image=<odf-must-gather-image> -- /usr/bin/gather -dpnc # Wrong
$ oc adm must-gather --image=<odf-must-gather-image> -- /usr/bin/gather -d -p -n -c # Correct
```
Examples:
```
$ /usr/bin/gather -d -n --ceph # Collect DR, nooba and ceph logs only.
$ /usr/bin/gather -h # Print help
$ oc adm must-gather --image=<odf-must-gather-image> -- /usr/bin/gather -d -n --ceph # Collect DR, nooba and ceph logs only.
$ oc adm must-gather --image=<odf-must-gather-image> -- /usr/bin/gather -h # Print help
```

The command above will create a local directory with a dump of the ODF state.
Expand Down
37 changes: 25 additions & 12 deletions collection-scripts/gather
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash

# Predefined operating modes
odf=false
dr=false
pc=false
nooba=false
Expand All @@ -16,12 +17,17 @@ pids=()

while [[ $# -gt 0 ]]; do
case "$1" in
-o | --odf)
odf=true
default=false
shift
;;
-d | --dr)
dr=true
default=false
shift
;;
-p | --provider*)
-pc | --provider*)
pc=true
default=false
shift
Expand Down Expand Up @@ -79,8 +85,9 @@ display_help() {
Usage: $0 [OPTIONS]

Options:
-o, --odf Collect ODF logs
-d, --dr Collect DR logs
-p, --provider Collect logs for provider/consumer cluster
-pc, --provider Collect openshift-storage-client logs from a provider/consumer cluster
-n, --nooba Collect nooba logs
-c, --ceph Collect ceph commands and pod logs
-cl, --ceph-logs Collect ceph daemon, kernel, journal logs and crash reports
Expand All @@ -95,16 +102,21 @@ Description:
will run in FULL collection mode and will gather all the resources
from your cluster. This might take longer on some environments.

Note: Provide each arg separately and do not chain them like:
$ $0 -dpnc # Wrong
$ $0 -d -p -n -c # Correct
Note: Provide each arg separately and do not chain them like:
$ oc adm must-gather --image=<odf-must-gather-image> -- $0 -dpnc # Wrong
$ oc adm must-gather --image=<odf-must-gather-image> -- $0 -d -p -n -c # Correct

Examples:
$ $0 -d -n --ceph # Collect DR, nooba and ceph logs only.
$ $0 -h # Print help
$ oc adm must-gather --image=<odf-must-gather-image> -- $0 -d -n --ceph # Collect DR, nooba and ceph logs only.
$ oc adm must-gather --image=<odf-must-gather-image> -- $0 -h # Print help
EOF
}

# If help is requested, we print it out and do nothing else (exit 0)
if [ "$help" = true ]; then
display_help && exit 0
fi

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

Expand All @@ -123,12 +135,13 @@ dbglog "collection started at: ${START_TIME}"
# Call pre-install.sh, see commit msg
pre-install.sh ${BASE_COLLECTION_PATH}

# If help is requested, we print it out and do nothing else (exit 0)
if [ "$help" = true ]; then
display_help && exit 0
# Process the options
if [ "$odf" == true ]; then
echo "Collect ODF logs..."
gather_main &
pids+=($!)
fi

# Process the options
if [ "$dr" == true ]; then
echo "Collect DR logs..."
gather_dr_resources ${BASE_COLLECTION_PATH} &
Expand Down Expand Up @@ -183,7 +196,7 @@ fi

# No args, normal op mode
if [ "$default" = true ]; then
echo "Gather will start in default op mode"
echo "No args detected, must-gather will start in default op mode"
gather_main
fi

Expand Down
2 changes: 2 additions & 0 deletions collection-scripts/gather_ceph_resources
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ for resource in "${ceph_resources[@]}"; do
done

namespaces=$(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)
namespaces="openshift-storage-extended"
# Inspecting the namespace where ocs-cluster is installed
for ns in $namespaces; do
dblog "collecting details of ns ${ns}"
ceph_collection() {
COMMAND_OUTPUT_DIR=${CEPH_COLLECTION_PATH}/must_gather_commands
COMMAND_JSON_OUTPUT_DIR=${CEPH_COLLECTION_PATH}/must_gather_commands_json_output
Expand Down
10 changes: 5 additions & 5 deletions collection-scripts/gather_namespaced_resources
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ commands_desc+=("pods")
commands_desc+=("hpa")
commands_desc+=("subscription")
commands_desc+=("storagecluster")
commands_desc+=("storagesystem")
commands_desc+=("storageconsumer")
commands_desc+=("storageprofiles")
commands_desc+=("storageclassrequest")
Expand Down Expand Up @@ -100,13 +101,12 @@ for INSTALL_NAMESPACE in $PRODUCT_NAMESPACE $INSTALL_NAMESPACES $MANAGED_FUSION_
# shellcheck disable=SC2086
{ oc describe ${command_desc} -n ${INSTALL_NAMESPACE}; } >>"${COMMAND_OUTPUT_FILE}"
done
# NOTE: This is a temporary fix for collecting the storagecluster as we are not able to collect the storagecluster using the inspect command
{ oc get storageclusters -n "${INSTALL_NAMESPACE}" -o yaml; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/storagecluster.yaml" 2>&1
{ oc get storagesystem -n "${INSTALL_NAMESPACE}" -o yaml; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/storagesystem.yaml" 2>&1
{ oc get storageconsumer -n "${INSTALL_NAMESPACE}" -o yaml; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/storageconsumer.yaml" 2>&1
done

# NOTE: This is a temporary fix for collecting the storagecluster as we are not able to collect the storagecluster using the inspect command
{ oc get storageclusters -n "${INSTALL_NAMESPACE}" -o yaml; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/storagecluster.yaml" 2>&1
{ oc get storagesystem -n "${INSTALL_NAMESPACE}" -o yaml; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/storagesystem.yaml" 2>&1
{ oc get storageconsumer -n "${INSTALL_NAMESPACE}" -o yaml; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/storageconsumer.yaml" 2>&1

# Collect oc get events with sorted timestamp
dbglog "collecting output of oc get events with sorted timestamp"
{ oc get event -o custom-columns="LAST SEEN:{lastTimestamp},FIRST SEEN:{firstTimestamp},COUNT:{count},NAME:{metadata.name},KIND:{involvedObject.kind},SUBOBJECT:{involvedObject.fieldPath},TYPE:{type},REASON:{reason},SOURCE:{source.component},MESSAGE:{message}" --sort-by=lastTimestamp -n openshift-storage; } >"${BASE_COLLECTION_PATH}/namespaces/${INSTALL_NAMESPACE}/oc_output/events_get" 2>&1
Expand Down
6 changes: 6 additions & 0 deletions collection-scripts/gather_odf_client
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CLIENT_OPERATOR_NAMESPACE=$(oc get subscriptions -A --no-headers | grep ocs-clie

# collection path for OC commands
mkdir -p "${BASE_COLLECTION_PATH}/odf-client/oc_output/"
mkdir -p "${BASE_COLLECTION_PATH}/csidriver"

# Command List
commands_get=()
Expand Down Expand Up @@ -109,3 +110,8 @@ for INSTALL_NAMESPACE in $STORAGE_CLIENT_NAMESPACE ; do
{ oc describe ${command_desc} -n ${INSTALL_NAMESPACE}; } >>"${COMMAND_OUTPUT_FILE}"
done
done

# collect csidriver details
{ oc get csidriver; } >"${BASE_COLLECTION_PATH}/csidriver/get_csidriver" 2>&1
{ oc describe csidriver -o yaml; } >"${BASE_COLLECTION_PATH}/csidriver/desc_csidriver" 2>&1
{ oc get csidriver -o yaml; } >"${BASE_COLLECTION_PATH}/csidriver/csidriver.yaml" 2>&1
Loading