Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1326588

Summary: Catch the "KeyboardInterrupt" when inputting "Ctrl+c" to end virt-who
Product: Red Hat Enterprise Linux 6 Reporter: Liushihui <shihliu>
Component: virt-whoAssignee: Chris Snyder <csnyder>
Status: CLOSED ERRATA QA Contact: Eko <hsun>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.8CC: hsun, ldai, rbalakri, sgao, shihliu, thozza
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: virt-who-0.18-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-03-21 10:30:25 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:
Bug Depends On:    
Bug Blocks: 1355878    

Description Liushihui 2016-04-13 07:44:49 UTC
Description of problem:
When virt-who run at CLI mode, input "Ctrl+c" will throw some KeyboardInterrupt info in the log, it also failed to kill virt-who.

Version-Release number of selected component (if applicable):
virt-who-0.16-8.el6.noarch
subscription-manager-1.16.8-8.el6.x86_64
python-rhsm-1.16.6-1.el6.x86_64

How reproducible:
10%

Steps to Reproduce:
1. Register system to satellite6.1
2. Run virt-who at CLI as the following, then input "Ctrl+c" to end virt-who
[root@dell-per720xd-01 virt-who.d]# virt-who --esx --esx-owner=ACME_Corporation --esx-env=Library --esx-server=10.73.2.95 --esx-username=Administrator --esx-password=Welcome1! -i 100 -d
2016-04-12 05:26:49,929 [virtwho.init INFO] MainProcess(24583):MainThread @virtwho.py:parseOptions:638 - Using reporter_id='dell-per720xd-01.rhts.eng.bos.redhat.com'
2016-04-12 05:26:49,938 [virtwho.init INFO] MainProcess(24583):MainThread @virtwho.py:main:730 - Using configuration "env/cmdline" ("esx" mode)
2016-04-12 05:26:49,943 [virtwho.main DEBUG] MainProcess(24583):MainThread @virtwho.py:run:231 - Starting infinite loop with 100 seconds interval
2016-04-12 05:26:50,249 [virtwho.env_cmdline DEBUG] Esx-1(24591):MainThread @virt.py:run:358 - Virt backend 'env/cmdline' started
2016-04-12 05:26:50,251 [virtwho.env_cmdline DEBUG] Esx-1(24591):MainThread @esx.py:_prepare:55 - Log into ESX
2016-04-12 05:26:53,442 [virtwho.env_cmdline DEBUG] Esx-1(24591):MainThread @esx.py:_prepare:58 - Creating ESX event filter
2016-04-12 05:26:56,448 [virtwho.env_cmdline DEBUG] Esx-1(24591):MainThread @virt.py:enqueue:351 - Report for config "env/cmdline" gathered, putting to queue for sending
2016-04-12 05:26:56,479 [virtwho.main DEBUG] MainProcess(24583):MainThread @subscriptionmanager.py:_connect:121 - Authenticating with certificate: /etc/pki/consumer/cert.pem
2016-04-12 05:26:56,670 [virtwho.main DEBUG] MainProcess(24583):MainThread @subscriptionmanager.py:hypervisorCheckIn:162 - Checking if server has capability 'hypervisor_async'
2016-04-12 05:26:56,830 [virtwho.main DEBUG] MainProcess(24583):MainThread @subscriptionmanager.py:hypervisorCheckIn:174 - Server does not have 'hypervisors_async' capability
2016-04-12 05:26:56,830 [virtwho.main INFO] MainProcess(24583):MainThread @subscriptionmanager.py:hypervisorCheckIn:185 - Sending update in hosts-to-guests mapping for config "env/cmdline": 2 hypervisors and 1 guests found
2016-04-12 05:26:56,833 [virtwho.main DEBUG] MainProcess(24583):MainThread @subscriptionmanager.py:hypervisorCheckIn:186 - Host-to-guest mapping: {
    "7a384d56-085c-0e32-c7ad-f7181c3f6ddf": [], 
    "3e504d56-3982-037b-f3e6-669289892fa1": [
        {
            "guestId": "4206405a-4133-bd0c-f8a5-9c7bc1355837", 
            "state": 1, 
            "attributes": {
                "active": 1, 
                "hypervisorVersion": "6.0.0", 
                "virtWhoType": "esx", 
                "hypervisorType": "VMware ESXi"
            }
        }
    ]
}
2016-04-12 05:26:57,114 [virtwho.main DEBUG] MainProcess(24583):MainThread @virtwho.py:send_report:161 - Report for config "env/cmdline" sent
2016-04-12 05:28:36,884 [virtwho.env_cmdline DEBUG] Esx-1(24591):MainThread @virt.py:enqueue:351 - Report for config "env/cmdline" gathered, putting to queue for sending
2016-04-12 05:28:36,892 [virtwho.main INFO] MainProcess(24583):MainThread @virtwho.py:run:309 - Report for config "env/cmdline" hasn't changed, not sending

*******************************Input "Ctrl+c"******************************
***************************************************************************
^C2016-04-12 05:29:41,370 [virtwho.main DEBUG] MainProcess(24583):MainThread @virtwho.py:terminate:360 - virt-who is shutting down
2016-04-12 05:29:41,369 [virtwho.env_cmdline DEBUG] Esx-1(24591):MainThread @virt.py:run:387 - Virt backend 'env/cmdline' interrupted


^CTraceback (most recent call last):
  File "/usr/share/virt-who/virtwho.py", line 816, in <module>
    exit(1)
  File "/usr/share/virt-who/virtwho.py", line 806, in exit
    virtWho.terminate()
  File "/usr/share/virt-who/virtwho.py", line 380, in terminate
Process Esx-1:
Traceback (most recent call last):
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 232, in _bootstrap
    self.stop_virts()
  File "/usr/share/virt-who/virtwho.py", line 356, in stop_virts
    virt.join()
  File "/usr/lib64/python2.6/multiprocessing/process.py", line 119, in join
    res = self._popen.wait(timeout)
  File "/usr/lib64/python2.6/multiprocessing/forking.py", line 122, in wait
    self.run()
  File "/usr/share/virt-who/virt/virt.py", line 388, in run
    self.cleanup()
  File "/usr/share/virt-who/virt/esx/esx.py", line 149, in cleanup
    return self.poll(0)
  File "/usr/lib64/python2.6/multiprocessing/forking.py", line 107, in poll
    pid, sts = os.waitpid(self.pid, flag)
KeyboardInterrupt    self._cancel_wait()

  File "/usr/share/virt-who/virt/esx/esx.py", line 63, in _cancel_wait
    self.client.service.CancelWaitForUpdates(_this=self.sc.propertyCollector)
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 542, in __call__
    return client.invoke(args, kwargs)
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 602, in invoke
    result = self.send(soapenv)
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 643, in send
    reply = transport.send(request)
  File "/usr/lib/python2.6/site-packages/suds/transport/https.py", line 64, in send
    return  HttpTransport.send(self, request)
  File "/usr/lib/python2.6/site-packages/suds/transport/http.py", line 77, in send
    fp = self.u2open(u2request)
  File "/usr/lib/python2.6/site-packages/suds/transport/http.py", line 118, in u2open
    return url.open(u2request, timeout=tm)
  File "/usr/lib64/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 1198, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib64/python2.6/urllib2.py", line 1163, in do_open
    r = h.getresponse()
  File "/usr/lib64/python2.6/httplib.py", line 1012, in getresponse
    response.begin()
  File "/usr/lib64/python2.6/httplib.py", line 404, in begin
    version, status, reason = self._read_status()
  File "/usr/lib64/python2.6/httplib.py", line 360, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "/usr/lib64/python2.6/socket.py", line 479, in readline
    data = self._sock.recv(self._rbufsize)
  File "/usr/lib64/python2.6/ssl.py", line 215, in recv
    return self.read(buflen)
  File "/usr/lib64/python2.6/ssl.py", line 136, in read
    return self._sslobj.read(len)
  File "/usr/share/virt-who/virt/virt.py", line 361, in <lambda>
    signal.signal(signal.SIGTERM, lambda *a: self.cleanup())
  File "/usr/share/virt-who/virt/esx/esx.py", line 152, in cleanup
    self.client.service.DestroyPropertyFilter(self.filter)
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 542, in __call__
    return client.invoke(args, kwargs)
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 602, in invoke
    result = self.send(soapenv)
  File "/usr/lib/python2.6/site-packages/suds/client.py", line 643, in send
    reply = transport.send(request)
  File "/usr/lib/python2.6/site-packages/suds/transport/https.py", line 64, in send
    return  HttpTransport.send(self, request)
  File "/usr/lib/python2.6/site-packages/suds/transport/http.py", line 77, in send
    fp = self.u2open(u2request)
  File "/usr/lib/python2.6/site-packages/suds/transport/http.py", line 118, in u2open
    return url.open(u2request, timeout=tm)
  File "/usr/lib64/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib64/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.6/urllib2.py", line 1198, in https_open
    return self.do_open(httplib.HTTPSConnection, req)
  File "/usr/lib64/python2.6/urllib2.py", line 1163, in do_open
    r = h.getresponse()
  File "/usr/lib64/python2.6/httplib.py", line 1012, in getresponse
    response.begin()
  File "/usr/lib64/python2.6/httplib.py", line 404, in begin
    version, status, reason = self._read_status()
  File "/usr/lib64/python2.6/httplib.py", line 360, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "/usr/lib64/python2.6/socket.py", line 479, in readline
    data = self._sock.recv(self._rbufsize)
  File "/usr/lib64/python2.6/ssl.py", line 215, in recv
    return self.read(buflen)
  File "/usr/lib64/python2.6/ssl.py", line 136, in read
    return self._sslobj.read(len)
KeyboardInterrupt
^C^C^C

Actual results:
Failed to end virt-who and show some KeyboardInterrupt info in the log.

Expected results:
Vrit-who thread should be killed after input "ctrl+c"


Additional info:

Comment 1 Radek Novacek 2016-05-05 12:08:15 UTC
This bug appears to be fixed upstream.

Comment 3 Radek Novacek 2016-10-11 14:04:50 UTC
Fixed in virt-who-0.18-1.el6.

Comment 5 Eko 2016-12-06 02:22:04 UTC
verified in virt-who-0.18-1.el6.noarch

Comment 6 Liushihui 2017-01-04 07:33:26 UTC
In virt-who-0.18-1.el6.noarch, Sometimes it still show KeyboardInterrupt info when inputting "Ctrl+c" to end virt-who. Therefore, reopen it.

How reproducible:
10%

Retest process:
1. Register system to satellite6.2
2. Run virt-who at CLI as the following, then input "Ctrl+c" to end virt-who
[root@hp-z220-13 virt-who.d]# virt-who -i 3 --esx --esx-owner=Default_Organization --esx-env=Library --esx-server=10.73.3.161 --esx-username=Administrator --esx-password=Welcome1!
2017-01-04 00:51:23,585 WARNING: Interval value can't be lower than 60 seconds. Default value of 60 seconds will be used.
2017-01-04 00:51:23,587 INFO: Using configuration "test-esx1" ("esx" mode)
2017-01-04 00:51:23,587 INFO: Using configuration "env/cmdline" ("esx" mode)
2017-01-04 00:51:23,588 INFO: Using reporter_id='hp-z220-13.qe.lab.eng.nay.redhat.com'
2017-01-04 00:51:28,371 INFO: Sending update in hosts-to-guests mapping for config "test-esx1": 2 hypervisors and 1 guests found
^C^CTraceback (most recent call last):
  File "/usr/bin/virt-who", line 9, in <module>
    load_entry_point('virt-who==0.18', 'console_scripts', 'virt-who')()
  File "/usr/lib/python2.6/site-packages/virtwho/__main__.py", line 31, in main
    x.join(1)
  File "/usr/lib64/python2.6/threading.py", line 655, in join
    self.__block.wait(delay)
  File "/usr/lib64/python2.6/threading.py", line 258, in wait
    _sleep(delay)
KeyboardInterrupt


Result:
It still show KeyboardInterrupt on terminal.

Comment 7 Chris Snyder 2017-01-05 15:45:45 UTC
Hey Eko,

It seems the original fix was helpful (seems to have fixed the issue 90% of the time). As fixing the 10% case above will require additional investigation and work and we are well into the release process for rhel 6.9 I believe we should open a new bug for the 10% case and leave this bug verified for the 90% case.


If this is acceptable to you please move this bug back to the VERIFIED state and open a new bug based on comment 6.

Comment 8 Eko 2017-01-17 15:07:19 UTC
hi shihui,
could you help to check this issue again? 
as Chris said, if still can reproduce, please verify this issue first and then open a new one.
thanks

Comment 9 Liushihui 2017-01-18 00:25:07 UTC
As comment 7 and comment 8, verified it as it can't reproduced every time.

Comment 11 errata-xmlrpc 2017-03-21 10:30:25 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-2017-0675.html