Bug 1327529

Summary: atomic top command doesn't work w/ the -o short option is separated by a space from the option argument
Product: Red Hat Enterprise Linux 7 Reporter: Alex Jia <ajia>
Component: atomicAssignee: Brent Baude <bbaude>
Status: CLOSED ERRATA QA Contact: atomic-bugs <atomic-bugs>
Severity: low Docs Contact:
Priority: low    
Version: 7.2CC: dwalsh, miabbott
Target Milestone: rcKeywords: Extras
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-04 09:05: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 Alex Jia 2016-04-15 10:11:18 UTC
Description of problem:
Very minor issue, as usual, a short option is separated by a space from the option argument, e.g. -n ARG or -nARG, but the atomic top -o {time,stime,ppid,uid,gid,user,group} <image> doesn't work.


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

[cloud-user@plat-infra-4zpfp3 ~]$ sudo atomic host status
  TIMESTAMP (UTC)         VERSION     ID             OSNAME               REFSPEC                                                        
* 2016-04-12 14:20:45     7.2.3-1     644fcc6035     rhel-atomic-host     rhel-atomic-host-ostree:rhel-atomic-host/7/x86_64/standard

[cloud-user@plat-infra-4zpfp3 ~]$ rpm -q atomic docker
atomic-1.9-4.gitff44c6a.el7.x86_64
docker-1.9.1-25.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1. docker run -d -it busybox /bin/sh
2. docker ps
3. atomic top -n 2 -o user <container_id>

Actual results:

[cloud-user@plat-infra-4zpfp3 ~]$ sudo docker ps
CONTAINER ID        IMAGE                                      COMMAND             CREATED             STATUS              PORTS               NAMES
194a92caef3f        busybox                                    "/bin/sh"           4 seconds ago       Up 3 seconds                            thirsty_brattain

[cloud-user@plat-infra-4zpfp3 ~]$ sudo atomic top -n 2 194a92caef3f|grep bin
194a92caef3f thirsty_brattain 15906      0.1    0.0    0      0      /bin/sh
194a92caef3f thirsty_brattain 15906      0.1    0.0    0      0      /bin/sh

[cloud-user@plat-infra-4zpfp3 ~]$ sudo atomic top -n 2 -ouser 194a92caef3f|grep -iA1 user
CONTA(I)NER* (N)AME           (P)ID      (C)PU  (M)EM  (U)ID  (G)ID  USER       CMD    
194a92caef3f thirsty_brattain 15906      0.0    0.0    0      0      root       /bin/sh
--
CONTA(I)NER* (N)AME           (P)ID      (C)PU  (M)EM  (U)ID  (G)ID  USER       CMD    
194a92caef3f thirsty_brattain 15906      0.0    0.0    0      0      root       /bin/sh

[cloud-user@plat-infra-4zpfp3 ~]$ sudo atomic top -n 2 -o=user 194a92caef3f|grep -iA1 user
CONTA(I)NER* (N)AME           (P)ID      (C)PU  (M)EM  (U)ID  (G)ID  USER       CMD    
194a92caef3f thirsty_brattain 15906      0.0    0.0    0      0      root       /bin/sh
--
CONTA(I)NER* (N)AME           (P)ID      (C)PU  (M)EM  (U)ID  (G)ID  USER       CMD    
194a92caef3f thirsty_brattain 15906      0.0    0.0    0      0      root       /bin/sh

[cloud-user@plat-infra-4zpfp3 ~]$ sudo atomic top -n 2 -o user 194a92caef3f|grep -iA1 user
/bin/atomic: argument -o/--optional: invalid choice: '194a92caef3f' (choose from 'time', 'stime', 'ppid', 'uid', 'gid', 'user', 'group')
Try 'atomic top --help' for more information.

NOTE: the short option should be separated by a space not '=' from the option argument


Expected results:

Additional info:

In addtion, it seems we have implemented many -o/--optional options[1], but it only supports {time,stime,ppid,uid,gid,user,group} options in -o/--optional now.

[1]
[root@dell-per630-02 atomic]# grep "'shortname':" Atomic/top.py
            {'shortname': '%CPU', 'column': '(C)PU', 'character': 'c', 'sort': True, 'index': 3,
            {'shortname': 'CID', 'column': 'CONTA(I)NER', 'character': 'i', 'sort': True, 'index': 0,
            {'shortname': 'NAME', 'column': '(N)AME', 'character': 'n', 'sort': True, 'index': 1,
            {'shortname': 'PID', 'column': '(P)ID', 'character': 'p', 'sort': True, 'index': 2,
            {'shortname': '%MEM', 'column': '(M)EM', 'character': 'm', 'sort': True, 'index': 4,
            {'shortname': 'CMD', 'column': 'CMD', 'character': None, 'sort': False, 'index': 99,
            {'shortname': 'TIME', 'column': '(T)IME', 'character': 't', 'sort': True, 'index': 6,
            {'shortname': 'STIME', 'column': '(S)TIME', 'character': 's', 'sort': True, 'index': 7,
            {'shortname': 'PPID', 'column': 'PPI(D)', 'character': 'd', 'sort': True, 'index': 8,
            {'shortname': 'UID', 'column': '(U)ID', 'character': 'u', 'sort': True, 'index': 9,
            {'shortname': 'GID', 'column': '(G)ID', 'character': 'g', 'sort': True, 'index': 10,
            {'shortname': 'USER', 'column': 'USER', 'character': None, 'sort': False, 'index': 11,
            {'shortname': 'GROUP', 'column': 'GROUP', 'character': None, 'sort': False, 'index': 12,


It's a trivial matter, so I think we may fix them in one patch.

Comment 2 Daniel Walsh 2016-08-26 19:00:06 UTC
Seems to work correctly in current release.

Fixed in atomic-1.10.

Comment 3 Alex Jia 2016-08-29 16:17:45 UTC
(In reply to Daniel Walsh from comment #2)
> Seems to work correctly in current release.
> 
> Fixed in atomic-1.10.

It still doesn't work for me.

[cloud-user@atomic-host-001 ~]$ rpm -q atomic
atomic-1.10.5-7.el7.x86_64

[cloud-user@atomic-host-001 ~]$ sudo atomic top -n 2 -o user 391f5e6bb67a
/usr/bin/atomic: argument -o/--optional: invalid choice: '391f5e6bb67a' (choose from 'time', 'stime', 'ppid', 'uid', 'gid', 'user', 'group')
Try 'atomic top --help' for more information.

Comment 4 Daniel Walsh 2016-08-29 16:32:21 UTC
Could you check atomic-1.11

Comment 5 Alex Jia 2016-08-29 16:40:12 UTC
(In reply to Daniel Walsh from comment #4)
> Could you check atomic-1.11

It also doesn't work on upstream atomic.

[root@dhcp-2-50 atomic]# git rev-parse HEAD
70c51001c07311aec1b72079e9c1917af80bcd3c

[root@dhcp-2-50 atomic]# ./atomic top -n 2 -o user a5ffa272e45a
atomic top: argument -o/--optional: invalid choice: 'a5ffa272e45a' (choose from 'time', 'stime', 'ppid', 'uid', 'gid', 'user', 'group')
Try 'atomic top --help' for more information.

Comment 6 Daniel Walsh 2016-08-29 17:17:38 UTC
Alex see if this fixes the issue for you

https://github.com/projectatomic/atomic/pull/569

Comment 7 Alex Jia 2016-08-30 00:51:37 UTC
(In reply to Daniel Walsh from comment #6)
> Alex see if this fixes the issue for you
> 
> https://github.com/projectatomic/atomic/pull/569

Daniel, it works well for me.

Comment 8 Daniel Walsh 2016-08-30 10:14:50 UTC
Fixed in atomic-1.12

Comment 10 Alex Jia 2016-09-18 02:59:52 UTC
This bug has been fixed in atomic-1.12.0-1.el7.x86_64, so moving to VERIFIED status.

Comment 12 errata-xmlrpc 2016-11-04 09:05: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, 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://rhn.redhat.com/errata/RHBA-2016-2628.html