Skip to content

Commit

Permalink
Merge pull request #19 from razo7/gain-more-info-must-gather
Browse files Browse the repository at this point in the history
gain more information by must-gather
  • Loading branch information
openshift-merge-robot authored Feb 24, 2022
2 parents 4027a5d + ca67b74 commit 158072e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
9 changes: 7 additions & 2 deletions must-gather/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

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

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


To collect this data, you must specify the extra image using the `--image` option.
Example:
Expand Down
30 changes: 25 additions & 5 deletions must-gather/collection-scripts/gather
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/bin/bash

mkdir -p /must-gather/
# Create a directory for must-gather
mkdir -p must-gather/operator-pod-logs/

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

OPERATOR_NAME="node-maintenance"

# Init named resource list, eg. ns/openshift-config
named_resources=()

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

# Get nmo logs - Nodes, CRD, and CRs
# Get NMO Information - nodes' object, CRD, pod's logs, CRs, cluster's resource usage.

# Get Nodes' names
# NODES_NAMES=($(oc get nodes -o jsonpath='{.items[*].metadata.name}{"\n"}'))

# Nodes
# Nodes' objects
group_resources+=(nodes)

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

# node maintenance CRs
# NMO's running POD name
NMO_PODS=($(oc get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' -n ${NMO_NAMESPACE} | grep 'node-maintenance'))

# Node Maintenance CRs
group_resources+=(nm)

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

# Get pod's logs for only the running pods. Dismiss drained NMO pods
for NMO_POD_NAME in ${NMO_PODS[@]};
do if [ $(oc get pod ${NMO_POD_NAME} -n ${NMO_NAMESPACE} -o jsonpath='{.status.phase}') == "Running" ];
then oc logs ${NMO_POD_NAME} -n ${NMO_NAMESPACE} > must-gather/operator-pod-logs/${NMO_POD_NAME}; fi; done

# Get cluster's resource (CPU and Memory) usage
oc adm top node --use-protocol-buffers > must-gather/cluster_resoruce_statistics

# Get all journal logs from each Node (TODO: select particluar journal logs, e.g., crio )
# for NODE in ${NODES_NAMES[@]}; do oc adm node-logs ${NODE} > must-gather/nodes-logs/${NODE}; done

exit 0

0 comments on commit 158072e

Please sign in to comment.