Skip to content

Commit

Permalink
Merge pull request #919 from jlojosnegros/must-gather-nro
Browse files Browse the repository at this point in the history
Gather NRO related data
  • Loading branch information
openshift-ci[bot] authored Jul 15, 2022
2 parents c8a7151 + 6c61d2b commit 75dac7e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
4 changes: 3 additions & 1 deletion must-gather/collection-scripts/gather
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ echo "performance-addon-operator/must-gather" > /must-gather/version
version >> /must-gather/version

. namespace
PAO_NAMESPACE=$( namespace )
PAO_NAMESPACE=$( pao_namespace )

# resource list
resources=()
Expand All @@ -28,5 +28,7 @@ done
# Collect nodes details
/usr/bin/gather_nodes

# Collect NRO details
/usr/bin/gather_nro
exit 0

17 changes: 17 additions & 0 deletions must-gather/collection-scripts/gather_nro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

# get crds
for crd_name in numaresourcesschedulers.nodetopology.openshift.io numaresourcesoperators.nodetopology.openshift.io noderesourcetopologies.topology.node.k8s.io
do
# get crd definition
oc adm inspect --dest-dir must-gather crd/${crd_name}

# get crd instances
oc adm inspect --dest-dir must-gather ${crd_name}
done

# Get NRO namespace and gather all the data there
. namespace
NRO_NAMESPACE=$(nro_namespace)

oc adm inspect --dest-dir must-gather ns/${NRO_NAMESPACE}
18 changes: 17 additions & 1 deletion must-gather/collection-scripts/namespace
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

function namespace() {
function pao_namespace() {
# we control the subs, so this is the most reliable way to get the namespace
ns=$( oc get subs -A --field-selector metadata.name='performance-addon-operator-subscription' -o=jsonpath='{.items[0].metadata.namespace}{"\n"}' 2> /dev/null )
# trying again with the pods, which are _usually_ reliable - but users can change them
Expand All @@ -11,3 +11,19 @@ function namespace() {
[ -z "${ns}" ] && ns="openshift-operators"
echo ${ns}
}

function nro_namespace() {
# we control the subs, so this is the most reliable way to get the namespace
ns=$( oc get subs -A --field-selector metadata.name='numaresources-operator-subscription' -o=jsonpath='{.items[0].metadata.namespace}{"\n"}' 2> /dev/null )

# trying again with the pods, which are _usually_ reliable - but users can change them
[ -z "${ns}" ] && ns=$( oc get pods -A -l name='resource-topology' -o=jsonpath='{.items[0].metadata.namespace}{"\n"}' 2> /dev/null )

# namespace suggested by the documentation. This is a fancier way to check for its existence
[ -z "${ns}" ] && ns=$(oc get ns openshift-numaresources -o=jsonpath='{.metadata.name}{"\n"}' 2> /dev/null )

# we should never get there. This is the last resort.
[ -z "${ns}" ] && ns="openshift-numaresources"

echo ${ns}
}

0 comments on commit 75dac7e

Please sign in to comment.