Skip to content

Commit 158072e

Browse files
Merge pull request #19 from razo7/gain-more-info-must-gather
gain more information by must-gather
2 parents 4027a5d + ca67b74 commit 158072e

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

must-gather/README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
You can use the `oc adm must-gather` command to collect information about your cluster.
44

5-
With the node-maintenance must-gather image you can collect manifests and logs related to node maintenance,
6-
which includes the node objects, and logs and manifests related to the node-maintenance-operator.
5+
With the node-maintenance-must-gather image you can collect manifests and logs related to node maintenance:
6+
- Node objects
7+
- Custom Resource Definition
8+
- Node Maintenance Operator pod's logs (dismiss drained pods)
9+
- Custom Resources
10+
- Cluster's resource (CPU, and Memory) usage
11+
712

813
To collect this data, you must specify the extra image using the `--image` option.
914
Example:

must-gather/collection-scripts/gather

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

3-
mkdir -p /must-gather/
3+
# Create a directory for must-gather
4+
mkdir -p must-gather/operator-pod-logs/
45

56
# Generate /must-gather/version file
67
DIR_NAME=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
78
. ${DIR_NAME}/version
89
echo "node-maintenance-operator/must-gather" > /must-gather/version
910
version >> /must-gather/version
1011

12+
OPERATOR_NAME="node-maintenance"
13+
1114
# Init named resource list, eg. ns/openshift-config
1215
named_resources=()
1316

@@ -17,21 +20,38 @@ group_resources=()
1720
# Get namespace of node-maintenance-operator - where it is installed
1821
NMO_NAMESPACE=$(oc get subs -A --field-selector=metadata.name=node-maintenance-operator -o jsonpath='{.items[*].metadata.namespace}')
1922

20-
# Get nmo logs - Nodes, CRD, and CRs
23+
# Get NMO Information - nodes' object, CRD, pod's logs, CRs, cluster's resource usage.
24+
25+
# Get Nodes' names
26+
# NODES_NAMES=($(oc get nodes -o jsonpath='{.items[*].metadata.name}{"\n"}'))
2127

22-
# Nodes
28+
# Nodes' objects
2329
group_resources+=(nodes)
2430

25-
# NMO CRD
31+
# NMO's CRD
2632
NMO_CRD=$(oc get crds -o jsonpath='{range .items[*]}{"crd/"}{.metadata.name}{"\n"}{end}' | grep 'nodemaintenance.medik8s' | sed -z 's/\n/ /g')
2733
named_resources+=(${NMO_CRD})
2834

29-
# node maintenance CRs
35+
# NMO's running POD name
36+
NMO_PODS=($(oc get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' -n ${NMO_NAMESPACE} | grep 'node-maintenance'))
37+
38+
# Node Maintenance CRs
3039
group_resources+=(nm)
3140

3241
# Run the Collection of Resources using inspect
3342
oc adm inspect --dest-dir must-gather --all-namespaces "${named_resources[@]}"
3443
group_resources_text=$(IFS=, ; echo "${group_resources[*]}")
3544
oc adm inspect --dest-dir must-gather --all-namespaces "${group_resources_text}"
3645

46+
# Get pod's logs for only the running pods. Dismiss drained NMO pods
47+
for NMO_POD_NAME in ${NMO_PODS[@]};
48+
do if [ $(oc get pod ${NMO_POD_NAME} -n ${NMO_NAMESPACE} -o jsonpath='{.status.phase}') == "Running" ];
49+
then oc logs ${NMO_POD_NAME} -n ${NMO_NAMESPACE} > must-gather/operator-pod-logs/${NMO_POD_NAME}; fi; done
50+
51+
# Get cluster's resource (CPU and Memory) usage
52+
oc adm top node --use-protocol-buffers > must-gather/cluster_resoruce_statistics
53+
54+
# Get all journal logs from each Node (TODO: select particluar journal logs, e.g., crio )
55+
# for NODE in ${NODES_NAMES[@]}; do oc adm node-logs ${NODE} > must-gather/nodes-logs/${NODE}; done
56+
3757
exit 0

0 commit comments

Comments
 (0)