Bug 757899 - Change "rhui-manager status" command to have meaningful exit codes.
Summary: Change "rhui-manager status" command to have meaningful exit codes.
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Update Infrastructure for Cloud Providers
Classification: Red Hat
Component: RHUA
Version: 2.0.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: James Slagle
QA Contact: wes hayutin
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-11-28 22:10 UTC by James Slagle
Modified: 2012-03-12 19:39 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-03-12 19:39:28 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description James Slagle 2011-11-28 22:10:30 UTC
"rhui-manager status" has non-zero exit codes to indicate problems, but they are not meaningful.

It should return documented exit codes that are meaningful to the user.  If there are multiple issues, the codes can be logically OR'd together to get the actual exit code that is returned the user.

Comment 1 James Slagle 2012-01-20 21:46:37 UTC
Committed in cloude repo 6715d0af111798fbe0edc61f0caadda4d0a9eb88

Comment 2 James Slagle 2012-01-20 21:49:10 UTC
Here are the possible return codes from the rhui-manager status command:

OK = 0
REPO_SYNC_ERROR = 1
CDS_SYNC_ERROR = 2
CDS_HEARTBEAT_ERROR = 4
IDENT_CERT_WARN = 8
IDENT_CERT_ERROR = 16
CA_CERT_WARN = 32
CA_CERT_ERROR = 64

If there is more than one problem that is encountered, the return codes are logically or'd together, so that you know exactly what happened.  E.g., say a repo sync error and a cds heartbeat error occurred, the return code would be 5 (1 | 4 = 5).

Comment 3 Kedar Bidarkar 2012-02-14 08:42:33 UTC
[root@xxxxxxx ~]# rhui-manager status
CDS1_173_191 ................................................ [  UP  ]

CDS1_173_191 ................................................ [  SUCCESS  ]
CDS2_109_224 ................................................ [  UP  ]

CDS2_109_224 ................................................ [  SUCCESS  ]

Red Hat Update Infrastructure 1.2 (Source RPMs) (5Server-x86_64) ...... [  ERROR  ]

Red Hat Enterprise Linux 6 Server (RPMs) from RHUI (6Server-x86_64) ... [  SUCCESS  ]

Red Hat Enterprise Linux 6 Server - Optional (RPMs) from RHUI (6Server-x86_64)  [  SUCCESS  ]

Identity certificate expiration date = 2022-02-07T07:35:51Z  .......... [  OK  ]

Entitlement CA certificate expiration date = 2012-07-25T16:36:58Z  .... [  OK  ]
1

these are two different nodes.

[root@yyyyyyyyy ~]# rhui-manager status

Identity certificate expiration date = 2012-02-15T08:35:17Z  .......... [  WARNING  ]
Identity certificate at /etc/pki/rhui/identity.crt will expire in 0 days.

Entitlement CA certificate expiration date = 2012-02-15T08:07:31Z  .... [  WARNING  ]
Entitlement CA certificate at /etc/pki/rhui/entitlement-ca.crt will expire in 0 days.
40
[root@ip-10-202-31-163 ~]# rhui-manager status

Identity certificate expiration date = 2012-02-15T08:35:17Z  .......... [  WARNING  ]
Identity certificate at /etc/pki/rhui/identity.crt will expire in 0 days.

Entitlement CA certificate expiration date = 2012-02-15T08:07:31Z  .... [  WARNING  ]
Entitlement CA certificate at /etc/pki/rhui/entitlement-ca.crt will expire in 0 days.
40
[root@ip-10-202-31-163 ~]# echo $?
40

Comment 4 Kedar Bidarkar 2012-02-15 11:51:44 UTC
[root@ip-10-202-31-163 ~]# rhui-manager status
CDS1_207_211 ................................................ [  UP  ]

CDS1_207_211 ................................................ [  ERROR  ]
CDS2_1_234 .................................................. [  UP  ]

CDS2_1_234 .................................................. [  ERROR  ]

Red Hat Enterprise Linux 6 Server (RPMs) from RHUI (6Server-x86_64) ... [  SUCCESS  ]

Identity certificate expiration date = 2012-02-15T08:35:17Z  .......... [  ERROR  ]
Identity certificate at /etc/pki/rhui/identity.crt is expired!

Entitlement CA certificate expiration date = 2012-02-15T08:07:31Z  .... [  ERROR  ]
Entitlement CA certificate at /etc/pki/rhui/entitlement-ca.crt is expired!
82

Comment 5 Kedar Bidarkar 2012-02-17 10:03:55 UTC
When syncs are "In Progress" the rhui-manager status incorrectly displays the status for that particular repo as ERROR.



[root@ip-10-82-231-94 ip-10-82-231-94.ec2.internal]# rhui-manager status
CDS1_221_38 ................................................. [  UP  ]

CDS1_221_38 ................................................. [  SUCCESS  ]
CDS2_18_15 .................................................. [ DOWN ]

CDS2_18_15 .................................................. [  ERROR  ]

Red Hat Enterprise Linux 5 Server from RHUI (RPMs) (5Server-x86_64) ... [  ERROR  ]

Red Hat Enterprise Linux 6 Server (RPMs) from RHUI (6Server-x86_64) ... [  SUCCESS  ]

Red Hat Enterprise Linux 6 Server - Supplementary (RPMs) from RHUI (6Server-x86_64)  [  SUCCESS  ]

Identity certificate expiration date = 2013-02-15T08:13:05Z  .......... [  OK  ]

Entitlement CA certificate expiration date = 2012-07-25T16:36:58Z  .... [  OK  ]
7

Comment 6 Kedar Bidarkar 2012-02-17 10:06:14 UTC
The ERROR tag for CDS2 is fine as it down to test failover.

The syncs from cdn where running for RHEL5 and the status shown is ERROR
Red Hat Enterprise Linux 5 Server from RHUI (RPMs) (5Server-x86_64) ... [ 
ERROR  ]

Comment 7 James Slagle 2012-02-17 18:36:29 UTC
The status command will never show a repo sync as IN PROGRESS.  This is a difference from seeing repo sync status from the rhui-manager shell.

However, it's in line with the behavior of most monitoring tools, such as nagios.  It continues to report as failed until it has recovered.  So, rhui-manager status will always show the status of the last sync regardless of whether or not a sync is running.

Comment 8 Kedar Bidarkar 2012-02-20 09:23:03 UTC
If in both the cases it displays "ERROR", that is for "In Progress" and "Error", We would always be forced to login into the rhui-manager and check via repo sync status whether it's actually an "Error" or the sync is "In Progress" state.

I completely agree with the monitoring tool kind of behaviour for "HEARTBEAT" of cds, but I feel not displaying it altogether until the sync is finished or displaying "In Progress" will be more helpful.

Also it would be confusing for people, related to consistency as to which is true.

Comment 9 James Slagle 2012-02-20 13:43:31 UTC
Yes, that's correct, the status command is meant to be used for monitoring, it is not meant to be functionally equivalent to the rhui-manager shell.  If you want to see what's in progress, you have to use the shell.

Even the shell reports the state as "Error" when its in progress:

Red Hat Enterprise Linux Server 6 (RPMs) (6Server-x86_64)
In Progress                  02-20-2012 02:06             Error      

The last column is the state.  In Progress only represents the last sync start time, which we don't display as part of the status command, so there's no place we'd say In Progress in that command output.

Also, in the shell, when you use vr to view a repository, we show it still to be in Error, and do not show in In Progress.  This repo is currently sync'ing (same repo as above):


Enter value (1-38) or 'b' to abort: 22

  Start Time:     02-20-2012 07:47
  Finish Time:    02-20-2012 07:48
  Elapsed Time:   0:01:00
  Result:         Error
  Exception:      Exception('Traceback (most recent call last):\n\n  File "/usr/lib/python2.6/site-packages/grinder/activeobject.py", line 447, in process\n    retval = method(*args, **kwargs)\n\n  File "/usr/lib/python2.6/site-packages/grinder/YumInfo.py", line 94, in getDownloadItems\n    self.__getRepoData()\n\n  File "/usr/lib/python2.6/site-packages/grinder/YumInfo.py", line 172, in __getRepoData\n    ftypefile = self.repo.retrieveMD(ftype)\n\n  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1551, in retrieveMD\n    return self._retrieveMD(mdtype)\n\n  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1607, in _retrieveMD\n    size=thisdata.size)\n\n  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 842, in _getFile\n    raise Errors.NoMoreMirrorsRepoError, errstr\n\nNoMoreMirrorsRepoError: failure: repodata/a7aef593e883caa4a3f523792154fa375c651cfd64d726ee16b122b4c84a39fa-updateinfo.xml.gz from : [Errno 256] No more mirrors to try.\n',)
  Traceback:
Traceback (most recent call last):


You can see it still shows Error, no mention of In Progress.  In Progress only shows up for the "dr" command.

I think the status command is actually very consistent with the use of the shell in this regard.  It's not meant to give any indication of running tasks.

Comment 10 Kedar Bidarkar 2012-02-20 14:19:20 UTC
ok moving to verfied state.

Comment 11 James Slagle 2012-03-12 19:39:28 UTC
Released in RHUI 2.0.2


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