Skip to content

Commit 3c1313a

Browse files
committed
Avoid error messages when NRO is not installed
must-gather is trying to get NRO related information (CRDs, and namespaced artifacts) no matter what and so, when NRO is not installed in the cluster some nasty error messages appear because those elements are not found. These are not errors but to avoid missleading the users it is better to avoid them by not gathering the NRO information if we cannot detect the NRO namespace. A small message appears in console in this case.
1 parent d8b6678 commit 3c1313a

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
#!/usr/bin/env bash
22

3-
# get crds
4-
for crd_name in numaresourcesschedulers.nodetopology.openshift.io numaresourcesoperators.nodetopology.openshift.io noderesourcetopologies.topology.node.k8s.io
5-
do
6-
# get crd definition
7-
oc adm inspect --dest-dir must-gather crd/${crd_name}
8-
9-
# get crd instances
10-
oc adm inspect --dest-dir must-gather ${crd_name}
11-
done
12-
133
# Get NRO namespace and gather all the data there
144
. namespace
155
NRO_NAMESPACE=$(nro_namespace)
166

17-
oc adm inspect --dest-dir must-gather ns/${NRO_NAMESPACE}
7+
if [ -z "$NRO_NAMESPACE" ]
8+
then
9+
echo "Numaresources Operator namespace not detected. Skipping NRO data gathering"
10+
else
11+
# get crds
12+
for crd_name in numaresourcesschedulers.nodetopology.openshift.io numaresourcesoperators.nodetopology.openshift.io noderesourcetopologies.topology.node.k8s.io
13+
do
14+
# get crd definition
15+
oc adm inspect --dest-dir must-gather crd/${crd_name}
16+
17+
# get crd instances
18+
oc adm inspect --dest-dir must-gather ${crd_name}
19+
done
20+
21+
oc adm inspect --dest-dir must-gather ns/${NRO_NAMESPACE}
22+
fi

must-gather/collection-scripts/namespace

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,5 @@ function nro_namespace() {
2222
# namespace suggested by the documentation. This is a fancier way to check for its existence
2323
[ -z "${ns}" ] && ns=$(oc get ns openshift-numaresources -o=jsonpath='{.metadata.name}{"\n"}' 2> /dev/null )
2424

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

0 commit comments

Comments
 (0)