Bug 1949820

Summary: Unable to use `oc adm top is` shortcut when asking for `imagestreams`
Product: OpenShift Container Platform Reporter: Leo Ochoa <lochoa>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED ERRATA QA Contact: zhou ying <yinzhou>
Severity: low Docs Contact:
Priority: low    
Version: 4.6.zCC: aos-bugs, jokerman, lochoa, mfojtik
Target Milestone: ---   
Target Release: 4.8.0   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: No Doc Update
Doc Text:
If this bug requires documentation, please select an appropriate Doc Type value.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-07-27 23:00:57 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 Leo Ochoa 2021-04-15 08:02:20 UTC
Description of problem:
From the list of `flags` available via the `oc adm top` command, the `imagestreams` cannot be requested using its alias (`ìs`), as per `no` or `po` when node and pods are requested respectively.

```
$ oc adm top
Show usage statistics of resources on the server
 This command analyzes resources managed by the platform and presents current usage statistics.
Usage:
  oc adm top [flags]
Available Commands:
  images       Show usage statistics for Images
  imagestreams Show usage statistics for ImageStreams
  node         Display Resource (CPU/Memory/Storage) usage of nodes
  pod          Display Resource (CPU/Memory/Storage) usage of pods
Use "oc adm <command> --help" for more information about a given command.
Use "oc adm options" for a list of global command-line options (applies to all commands)
```


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

$ oc version
Client Version: 4.6.1
Kubernetes Version: v1.19.0+d59ce34


This can be corroborated here:
```
$ oc adm top is
error: unknown command "is"
See 'oc adm top -h' for help and examples
```
```
$ oc adm top no
NAME          CPU(cores)       CPU%        MEMORY (bytes)       MEMORY%
master01      2297m            65%         5195Mi               34%
```


The aliases of `imagestreams` and `nodes` can be found here:
```
$ oc api-resources | grep "imagestreams\|nodes"
nodes                                 no                                                     false        Node
imagestreams                          is               image.openshift.io                    true         ImageStream
```


This's implemented in upstream `kubectl` (for `NewCmdTopNode`) as shown here: https://github.com/kubernetes/kubectl/blob/master/pkg/cmd/top/top_node.go#L88

A patch PR can be found here (https://github.com/openshift/oc/pull/810), but it'd need review probably.

Comment 2 zhou ying 2021-04-22 02:09:19 UTC
Can't reproduce with latest oc :

[root@localhost ~]# ./oc adm top is 
NAME                                                          STORAGE  IMAGES LAYERS 
openshift/jboss-datavirt64-openshift                          8.633GiB 8      50     
openshift/fuse7-eap-openshift                                 7.242GiB 9      45   
....


[root@localhost ~]# ./oc version  --client -o yaml 
clientVersion:
  buildDate: "2021-04-21T18:11:19Z"
  compiler: gc
  gitCommit: a5f16de8b05e251fe5195adedd4192c2ca66bbad
  gitTreeState: clean
  gitVersion: 4.8.0-202104211714.p0-a5f16de
  goVersion: go1.16.1
  major: ""
  minor: ""
  platform: linux/amd64
releaseClientVersion: 4.8.0-0.nightly-2021-04-21-201409

Comment 5 errata-xmlrpc 2021-07-27 23:00:57 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.8.2 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-2021:2438