Bug 1444641

Summary: virsh plugin uncaught exception when unable to connect to the hypervisor
Product: Red Hat Enterprise Linux 7 Reporter: Pavel Moravec <pmoravec>
Component: sosAssignee: Pavel Moravec <pmoravec>
Status: CLOSED ERRATA QA Contact: Miroslav HradĂ­lek <mhradile>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: agk, bmr, gavin, mhradile, plambri, sbradley
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: All   
OS: Linux   
URL: https://github.com/sosreport/sos/pull/997
Whiteboard:
Fixed In Version: sos-3.4-3.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 23:10:42 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 Pavel Moravec 2017-04-23 14:22:02 UTC
Description of problem:
When virsh -r <subcommand> fails to connect to the hypervisor, and virsh plugin is enabled in sosreport, then it produces backtrace:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1252, in setup
    plug.setup()
  File "/usr/lib/python2.7/site-packages/sos/plugins/virsh.py", line 59, in setup
    pos = k_lines[0].split().index('Name')
ValueError: 'Name' is not in list

Reason:
 53         for k in ['net', 'nwfilter', 'pool']:
 54             self.add_cmd_output('%s %s-list' % (cmd, k))
 55             k_file = self.get_cmd_output_now('%s %s-list' % (cmd, k))
 56             if k_file:
 57                 k_lines = open(k_file, 'r').read().splitlines()
 58                 # the 'name' column position changes between virsh cmds
 59                 pos = k_lines[0].split().index('Name')

cmd on line 54 calls virsh that returns the failure:

['error: failed to connect to the hypervisor', "error: Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': No such file or directory", '']

that does not contain 'Name' substring either where.


Version-Release number of selected component (if applicable):
sos-3.4-2.el7.noarch


How reproducible:
100%


Steps to Reproduce:
1. Switch off libvirt hypervisor / in some other means, cause the "virsh -r net-list" command generates the above error.
2. sosreport --batch -o virsh


Actual results:
caught exception in plugin method "virsh.setup()"
writing traceback to sos_logs/virsh-plugin-errors.txt
..
and the virsh-plugin-errors.txt has:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1252, in setup
    plug.setup()
  File "/usr/lib/python2.7/site-packages/sos/plugins/virsh.py", line 59, in setup
    pos = k_lines[0].split().index('Name')
ValueError: 'Name' is not in list


Expected results:
no such error


Additional info:

Comment 2 Pavel Moravec 2017-04-25 15:12:25 UTC
In fact this is a regression: current sos-3.3-5.el7_3.noarch does not generate the traceback / exception, in the same situation.

Comment 6 errata-xmlrpc 2017-08-01 23:10:42 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-2017:2203