Bug 808351

Summary: Simulating unreachable rhn causes an exception during rhui-manager status display
Product: Red Hat Update Infrastructure for Cloud Providers Reporter: mkovacik
Component: RHUAAssignee: wes hayutin <whayutin>
Status: CLOSED ERRATA QA Contact: mkovacik
Severity: unspecified Docs Contact:
Priority: high    
Version: 2.1CC: dmacpher, kbidarka, sghai, tsanders
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Running "rhui-manager status" during a connection failure causes an uncaught exception. As a consequence, "rhui-manager status" report a traceback error instead of a status message. This fix adds an exception that prints the following error message if communication is unavailable: "Network error while connecting to the RHUA, please check the server is running and available" This means "rhui-manager status" runs successfully without any traceback error.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-08-24 11:53:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
patch to catch network issues w/ rhui-manager connecting to pulp
none
Verifying screen log none

Description mkovacik 2012-03-30 08:24:10 UTC
Description of problem:
Trying to simulate connection problems with RHN the 'rhui-manager status' command fails with an uncaught exception instead of displaying status and exiting with return code 1.

Version-Release number of selected component (if applicable):
RHEL-6.2-RHUI-2.0.3-20120322.0-Server-x86_64-DVD1.iso

How reproducible:
Always

Steps to Reproduce:
1. disable outgoing 443 traffic from rhua in iptables 
2. run rhui-manager status
  
Actual results:
Stack trace instead of status information

Expected results:
Status information displayed; command returns with exit code 1

Additional info:
### SCREEN LOG
[root@ip-10-51-53-253 ~]# fg -
vim /etc/sysconfig/iptables

[1]+  Stopped                 vim /etc/sysconfig/iptables
[root@ip-10-51-53-253 ~]# service iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
[root@ip-10-51-53-253 ~]# service iptables status
Table: filter
Chain INPUT (policy DROP)
num  target     prot opt source               destination
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination
1    REJECT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:443 reject-with icmp-port-unreachable

[root@ip-10-51-53-253 ~]# jobs
[1]+  Stopped                 vim /etc/sysconfig/iptables
[root@ip-10-51-53-253 ~]# rhui-manager

------------------------------------------------------------------------------
             -= Red Hat Update Infrastructure Management Tool =-


-= Home =-

   r   manage repositories
   c   manage content delivery servers (CDS)
   s   synchronization status and scheduling
   e   create entitlement certificates and client configuration RPMs
   n   manage Red Hat entitlement certificates
   u   manage users
   i   manage identity certificate

   logout
       removes stored authentication credentials and exits

   <   move to the previous screen
   ^, home
       move to the home screen
   /, clear
       clears the screen
   ?, help
       display help
   q, quit, exit
       exit

                         Connected: ip-10-51-53-253.eu-west-1.compute.internal
------------------------------------------------------------------------------
rhui (home) => s

------------------------------------------------------------------------------
             -= Red Hat Update Infrastructure Management Tool =-


-= Synchronization Status =-

   dr  display repo sync summary
   vr  view the details of the last repository sync
   sr  sync an individual repository immediately
   dc  display CDS sync summary
   vc  view the details of the last CDS sync
   sc  sync an individual CDS immediately

                         Connected: ip-10-51-53-253.eu-west-1.compute.internal
------------------------------------------------------------------------------
rhui (sync) => sr


An unexpected error has occurred during the last operation.
More information can be found in /root/.rhui/rhui.log.


------------------------------------------------------------------------------
             -= Red Hat Update Infrastructure Management Tool =-


-= Synchronization Status =-

   dr  display repo sync summary
   vr  view the details of the last repository sync
   sr  sync an individual repository immediately
   dc  display CDS sync summary
   vc  view the details of the last CDS sync
   sc  sync an individual CDS immediately

   logout
       removes stored authentication credentials and exits

   <   move to the previous screen
   ^, home
       move to the home screen
   /, clear
       clears the screen
   ?, help
       display help
   q, quit, exit
       exit

                         Connected: ip-10-51-53-253.eu-west-1.compute.internal
------------------------------------------------------------------------------
rhui (sync) => q
[root@ip-10-51-53-253 ~]# rhui-manager status
Traceback (most recent call last):
  File "/usr/bin/rhui-manager", line 16, in <module>
    rhui.tools.launcher.main()
  File "/usr/lib/python2.6/site-packages/rhui/tools/launcher.py", line 341, in main
    cli.run(args)
  File "/usr/lib/python2.6/site-packages/rhui/common/cli.py", line 276, in run
    command_or_section.execute(remaining_args)
  File "/usr/lib/python2.6/site-packages/rhui/common/cli.py", line 117, in execute
    self.method(**arg_dict)
  File "/usr/lib/python2.6/site-packages/rhui/tools/commands/status.py", line 51, in show
    ret_code = self._status(kwargs['--code'])
  File "/usr/lib/python2.6/site-packages/rhui/tools/commands/status.py", line 60, in _status
    cds_instances = self.pulp.cds_with_sync_status()
  File "/usr/lib/python2.6/site-packages/rhui/tools/pulp_api.py", line 556, in cds_with_sync_status
    cds_list = self.cds_list()
  File "/usr/lib/python2.6/site-packages/rhui/tools/pulp_api.py", line 541, in cds_list
    cds_list = self.cds_api.list()
  File "/usr/lib/python2.6/site-packages/pulp/client/api/cds.py", line 50, in list
    return self.server.GET(path)[1]
  File "/usr/lib/python2.6/site-packages/pulp/client/api/server.py", line 317, in GET
    return self._request('GET', path, queries)
  File "/usr/lib/python2.6/site-packages/pulp/client/api/server.py", line 264, in _request
    connection.request(method, url, body=body, headers=self.headers)
  File "/usr/lib64/python2.6/httplib.py", line 914, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib64/python2.6/httplib.py", line 951, in _send_request
    self.endheaders()
  File "/usr/lib64/python2.6/httplib.py", line 908, in endheaders
    self._send_output()
  File "/usr/lib64/python2.6/httplib.py", line 780, in _send_output
    self.send(msg)
  File "/usr/lib64/python2.6/httplib.py", line 739, in send
    self.connect()
  File "/usr/lib64/python2.6/site-packages/M2Crypto/httpslib.py", line 50, in connect
    self.sock.connect((self.host, self.port))
  File "/usr/lib64/python2.6/site-packages/M2Crypto/SSL/Connection.py", line 181, in connect
    self.socket.connect(addr)
  File "<string>", line 1, in connect
socket.error: [Errno 111] Connection refused
[root@ip-10-51-53-253 ~]#

Comment 1 wes hayutin 2012-05-17 15:40:20 UTC
You get the same error if the pulp server is just shutdown, will look for a good place to catch the error..


whayutin@minidoe tools]$ PYTHONPATH=src/ bin/rhui-manager --config dev/rhui-tools.conf status
Traceback (most recent call last):
  File "bin/rhui-manager", line 16, in <module>
    rhui.tools.launcher.main()
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/tools/launcher.py", line 341, in main
    cli.run(args)
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/common/cli.py", line 276, in run
    command_or_section.execute(remaining_args)
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/common/cli.py", line 117, in execute
    self.method(**arg_dict)
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/tools/commands/status.py", line 51, in show
    ret_code = self._status(kwargs['--code'])
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/tools/commands/status.py", line 60, in _status
    cds_instances = self.pulp.cds_with_sync_status()
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/tools/pulp_api.py", line 578, in cds_with_sync_status
    cds_list = self.cds_list()
  File "/home/whayutin/workspace/cloude/rhui-2.0/tools/src/rhui/tools/pulp_api.py", line 543, in cds_list
    cds_list = self.cds_api.list()
  File "/home/whayutin/workspace/pulp/src/pulp/client/api/cds.py", line 50, in list
    return self.server.GET(path)[1]
  File "/home/whayutin/workspace/pulp/src/pulp/client/api/server.py", line 317, in GET
    return self._request('GET', path, queries)
  File "/home/whayutin/workspace/pulp/src/pulp/client/api/server.py", line 264, in _request
    connection.request(method, url, body=body, headers=self.headers)
  File "/usr/lib/python2.7/httplib.py", line 941, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python2.7/httplib.py", line 975, in _send_request
    self.endheaders(body)
  File "/usr/lib/python2.7/httplib.py", line 937, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python2.7/httplib.py", line 797, in _send_output
    self.send(msg)
  File "/usr/lib/python2.7/httplib.py", line 759, in send
    self.connect()
  File "/usr/lib/python2.7/site-packages/M2Crypto/httpslib.py", line 50, in connect
    self.sock.connect((self.host, self.port))
  File "/usr/lib/python2.7/site-packages/M2Crypto/SSL/Connection.py", line 181, in connect
    self.socket.connect(addr)
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 111] Connection refused

Comment 2 wes hayutin 2012-05-17 16:34:57 UTC
Created attachment 585271 [details]
patch to catch network issues w/ rhui-manager connecting to pulp

added socket exception

Comment 3 wes hayutin 2012-05-18 19:40:25 UTC
cloude commit e6c9ddfab5f746d83e5c58a8ee7eec663027f023

Comment 5 mkovacik 2012-07-19 12:58:10 UTC
Switching to verified based on comment 4

Comment 6 Dan Macpherson 2012-08-14 03:22:50 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Running "rhui-manager status" during a connection failure causes an uncaught exception. As a consequence, "rhui-manager status" report a traceback error instead of a status message. This fix adds an exception that prints the following error message if communication is unavailable:

"Network error while connecting to the RHUA, please check the server is running and available"

This means "rhui-manager status" runs successfully without any traceback error.

Comment 8 errata-xmlrpc 2012-08-24 11:53:47 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.

http://rhn.redhat.com/errata/RHEA-2012-1205.html