Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 2112934

Summary: The oc adm inspect ns/[namespace_name] command is not collecting the servicemonitors in the namespace
Product: OpenShift Container Platform Reporter: oarribas <oarribas>
Component: ocAssignee: Arda Guclu <aguclu>
oc sub component: oc QA Contact: zhou ying <yinzhou>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: low CC: aguclu, jchaloup, mfojtik, oarribas
Version: 4.10Keywords: Reopened
Target Milestone: ---   
Target Release: 4.12.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-01-17 19:54:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description oarribas 2022-08-01 14:43:14 UTC
Description of problem:

When using the `oc adm inspect` command in a namespace, the `servicemonitors` in that `namespace` are missing from the resulting inspect.


Version-Release number of selected component (if applicable):

4.10


How reproducible:

Create an inspect from a `namespace` with several servicemonitors, like `openshift-monitoring`, and check the resulting inspect.


Steps to Reproduce:
1. $ oc adm inspect openshift-monitoring
2. $ find . -name "*servicemonitor*"



Actual results:

There are no `servicemonitor` yamls in the resulting inspect.



Expected results:

The `servicemonitor` yamls in the inspect.



Additional info:

The `oc adm inspect` collects the `servicemonitors` when using directly with the `servicemonitor` resource:
~~~
$ oc adm inspect servicemonitor -n openshift-monitoring

$ ls -ltrh */namespaces/openshift-monitoring/monitoring.coreos.com/servicemonitors/
total 64K
-rwxr-xr-x. 1 quicklab quicklab 2,0K ago  1 10:39 alertmanager-main.yaml
-rwxr-xr-x. 1 quicklab quicklab 1,3K ago  1 10:39 cluster-monitoring-operator.yaml
-rwxr-xr-x. 1 quicklab quicklab 1,4K ago  1 10:39 etcd.yaml
-rwxr-xr-x. 1 quicklab quicklab 1,6K ago  1 10:39 grafana.yaml
-rwxr-xr-x. 1 quicklab quicklab 2,4K ago  1 10:39 kube-state-metrics.yaml
-rwxr-xr-x. 1 quicklab quicklab 9,9K ago  1 10:39 kubelet.yaml
-rwxr-xr-x. 1 quicklab quicklab 2,0K ago  1 10:39 node-exporter.yaml
-rwxr-xr-x. 1 quicklab quicklab 2,0K ago  1 10:39 prometheus-adapter.yaml
-rwxr-xr-x. 1 quicklab quicklab 1,7K ago  1 10:39 openshift-state-metrics.yaml
-rwxr-xr-x. 1 quicklab quicklab 2,0K ago  1 10:39 prometheus-k8s.yaml
-rwxr-xr-x. 1 quicklab quicklab 1,4K ago  1 10:39 telemeter-client.yaml
-rwxr-xr-x. 1 quicklab quicklab 1,9K ago  1 10:39 prometheus-operator.yaml
-rwxr-xr-x. 1 quicklab quicklab 1,8K ago  1 10:39 thanos-sidecar.yaml
-rwxr-xr-x. 1 quicklab quicklab 2,0K ago  1 10:39 thanos-querier.yaml
~~~

Comment 1 Arda Guclu 2022-08-03 11:22:33 UTC
`oc adm inspect ns/openshift-monitoring` command only supports common resources that mostly exist in various namespaces, since must-gather also uses that command. When I checked in must-gather, inspection is executed for a few namespaces(https://github.com/openshift/must-gather/blob/63488d47e68294b8feab1f06698ffb6b57778a3f/collection-scripts/gather#L28). Thereby, adding `ServiceMonitor` inspection in `oc adm inspect` will already not be used by must-gather.

In addition to that, when I ran `oc adm inspect servicemonitor` in different namespaces(kube-system, openshift-apiserver, etc.), only a few of them returned resources.

I think, it would be better continuing using `oc adm inspect servicemonitor -n openshift-monitoring` as an supportive additional resource to `oc adm inspect ns/openshift-monitoring`.

Comment 6 zhou ying 2022-08-24 06:01:57 UTC
oc version --client
Client Version: 4.12.0-0.nightly-2022-08-23-223922
Kustomize Version: v4.5.4


[root@localhost ~]# oc adm inspect ns/openshift-monitoring
Gathering data for ns/openshift-monitoring...
W0824 13:58:17.814395   19384 util.go:119] the server doesn't have a resource type egressfirewalls, skipping the inspection
Wrote inspect data to inspect.local.8994323742603699922.
[root@localhost ~]# cd inspect.local.8994323742603699922/
[root@localhost inspect.local.8994323742603699922]# find . -name "*servicemonitor*"
./namespaces/openshift-monitoring/monitoring.coreos.com/servicemonitors.yaml

Comment 11 errata-xmlrpc 2023-01-17 19:54:07 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.12.0 bug fix and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:7399