Bug 2112934 - The oc adm inspect ns/[namespace_name] command is not collecting the servicemonitors in the namespace
Summary: The oc adm inspect ns/[namespace_name] command is not collecting the servicem...
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.10
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
: 4.12.0
Assignee: Arda Guclu
QA Contact: zhou ying
Depends On:
TreeView+ depends on / blocked
Reported: 2022-08-01 14:43 UTC by oarribas
Modified: 2023-01-17 19:54 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Last Closed: 2023-01-17 19:54:07 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Github openshift oc issues 1216 0 None open The `oc adm inspect ns/[namespace_name]` command is not collecting the `servicemonitors` in the `namespace` 2022-08-19 09:58:38 UTC
Github openshift oc pull 1224 0 None Merged Bug 2112934: Add servicemonitors into common namespaces for inspection 2022-08-19 09:58:38 UTC
Red Hat Product Errata RHSA-2022:7399 0 None None None 2023-01-17 19:54:22 UTC

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):


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*"

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.


Note You need to log in before you can comment on or make changes to this bug.