Bug 1710750

Summary: Catch and translate LibraryError exceptions
Product: Red Hat Enterprise Linux 7 Reporter: Tomas Jelinek <tojeline>
Component: pcsAssignee: Tomas Jelinek <tojeline>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 7.6CC: cfeist, cluster-maint, idevat, mmazoure, omular, tojeline
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: pcs-0.9.168-1.el7 Doc Type: Bug Fix
Doc Text:
Cause: LibraryError exceptions which pcs uses for passing errors internally were not always caught and processed to human-readable form. Consequence: Pcs crashed with a traceback. Fix: Catch LibraryError exceptions at the top level and translate them. Result: Pcs exits gracefully with a readable error message.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-31 19:09:37 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:
Attachments:
Description Flags
proposed fix none

Description Tomas Jelinek 2019-05-16 08:57:33 UTC
Description of problem:
When a new function which may raise a LibraryError exception is called from an old-architecture pcs code, the exception is not always caught and produces a traceback.

All LibrayError exceptions should be caught in app.py and translated to human-readable messages. This has already been done in pcs-0.10 branch.


Version-Release number of selected component (if applicable):
pcs-0.9.165-6.el7


How reproducible:
always, easily


Steps to Reproduce:
1. # mv /usr/sbin/crm_mon /usr/sbin/crm_mon_
2. # pcs status
3. # mv /usr/sbin/crm_mon_ /usr/sbin/crm_mon


Actual results:
Traceback (most recent call last):
  File "/usr/sbin/pcs", line 9, in <module>
    load_entry_point('pcs==0.9.165', 'console_scripts', 'pcs')()
  File "/usr/lib/python2.7/site-packages/pcs/app.py", line 212, in main
    cmd_map[command](argv)
  File "/usr/lib/python2.7/site-packages/pcs/app.py", line 176, in <lambda>
    utils.get_modifiers()
  File "/usr/lib/python2.7/site-packages/pcs/status.py", line 28, in status_cmd
    full_status()
  File "/usr/lib/python2.7/site-packages/pcs/status.py", line 74, in full_status
    stdout, stderr, retval = utils.cmd_runner().run(monitor_command)
  File "/usr/lib/python2.7/site-packages/pcs/lib/external.py", line 428, in run
    reports.run_external_process_error(log_args, e.strerror)
pcs.lib.errors.LibraryError: ERROR RUN_EXTERNAL_PROCESS_ERROR: {'reason': 'No such file or directory', 'command': 'crm_mon --one-shot --inactive'} forceable: None


Expected results:
Error: unable to run command /usr/sbin/crm_mon --one-shot --inactive: No such file or directory: '/usr/sbin/crm_mon'


Additional info:
FAF reports:
https://retrace.fedoraproject.org/faf/reports/2407183/
https://retrace.fedoraproject.org/faf/reports/2402402/

Comment 1 Tomas Jelinek 2019-06-28 16:01:51 UTC
Created attachment 1585679 [details]
proposed fix

Test is in comment 0.

Comment 3 Ivan Devat 2019-08-05 11:24:05 UTC
After Fix:

[kid76 ~] $ rpm -q pcs
pcs-0.9.168-1.el7.x86_64

[kid76 ~] $ mv /usr/sbin/crm_mon /usr/sbin/crm_mon_
[kid76 ~] $ pcs status
Error: unable to run command /usr/sbin/crm_mon --one-shot --inactive: No such file or directory
[kid76 ~] $ mv /usr/sbin/crm_mon_ /usr/sbin/crm_mon

Comment 7 errata-xmlrpc 2020-03-31 19:09:37 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://access.redhat.com/errata/RHBA-2020:0996