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

Bug 2062355: Collect NMState resources when operator is installed #292

Merged
merged 1 commit into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions collection-scripts/gather
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,8 @@ oc adm inspect --dest-dir must-gather --rotated-pod-logs "${group_resources_text
# Gather metallb logs
/usr/bin/gather_metallb_logs

# Gather NMState
/usr/bin/gather_nmstate

# force disk flush to ensure that all data gathered is accessible in the copy container
sync
28 changes: 28 additions & 0 deletions collection-scripts/gather_nmstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
BASE_COLLECTION_PATH="must-gather"
NMSTATE_NS="$(oc get subs -A -o template --template '{{range .items}}{{if eq .spec.name "kubernetes-nmstate-operator"}}{{.metadata.namespace}}{{end}}{{end}}')"
NMSTATE_API_GROUP="nmstate.io"

if [ -z "${NMSTATE_NS}" ]; then
echo "INFO: NMState not detected. Skipping."
exit 0
fi

function get_nmstate_cr() {
declare -a NMSTATE_CRDS=("nmstates" "nodenetworkconfigurationenactments" "nodenetworkconfigurationpolicies" "nodenetworkstates")
for NMSTATE_CRD in "${NMSTATE_CRDS[@]}"; do
CR_PATH="${BASE_COLLECTION_PATH}/cluster-scoped-resources/${NMSTATE_API_GROUP}/${NMSTATE_CRD}"
mkdir -p ${CR_PATH}

for CR_NAME in $(oc get ${NMSTATE_CRD} -ojsonpath='{.items[*].metadata.name}'); do
oc get ${NMSTATE_CRD} ${CR_NAME} -o yaml > "${CR_PATH}/${CR_NAME}.yaml"
done
done
}

oc adm inspect --dest-dir must-gather "ns/${NMSTATE_NS}"

get_nmstate_cr

# force disk flush to ensure that all data gathered is accessible in the copy container
sync