Bug 1371759

Summary: Unregister system will result in "ConnectionError:" with xen server
Product: Red Hat Enterprise Linux 7 Reporter: Liushihui <shihliu>
Component: virt-whoAssignee: candlepin-bugs
Status: CLOSED CURRENTRELEASE QA Contact: Eko <hsun>
Severity: low Docs Contact:
Priority: medium    
Version: 7.3CC: ldai, redakkan, sgao, wpoteat, yuefliu
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-13 18:52:17 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:

Description Liushihui 2016-08-31 03:11:54 UTC
Description of problem:
When virt-who work at xen mode, it will show "ConnectionError: ('Connection aborted.', error(4, 'Interrupted system call'))" after unregister system.

Version-Release number of selected component (if applicable):
virt-who-0.17-10.el7.noarch
subscription-manager-1.17.10-1.el7.x86_64
python-rhsm-1.17.6-1.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Register system to satellite6

2. Configure virt-who run at xen mode and restart virt-who service ,virt-who can send mapping info successfully to server.
[root@ibm-hs21-12 ~]# cat /etc/sysconfig/virt-who  | grep -v ^# | grep -v ^$
VIRTWHO_DEBUG=1
VIRTWHO_XEN=1
VIRTWHO_XEN_OWNER=ACME_Corporation
VIRTWHO_XEN_ENV=Library
VIRTWHO_XEN_SERVER=10.73.131.183
VIRTWHO_XEN_USERNAME=root
VIRTWHO_XEN_PASSWORD=Welcome1

3. Unregister system and check rhsm log.
[root@ibm-hs21-12 ~]# subscription-manager  unregister
System has been unregistered.
[root@ibm-hs21-12 ~]# tail -f /var/log/rhsm/rhsm.log
2016-08-30 22:59:20,763 [DEBUG] rhsmd:32203:MainThread @identity.py:146 - Reload of consumer identity cert /etc/pki/consumer/cert.pem raised an exception with msg: [Errno 2] No such file or directory: '/etc/pki/consumer/key.pem'
2016-08-30 22:59:20,763 [DEBUG] rhsmd:32203:MainThread @rhsmd:183 - D-Bus signal com.redhat.SubscriptionManager.EntitlementStatus.entitlement_status_changed emitted
2016-08-30 22:59:20,764 [DEBUG] rhsmd:32203:MainThread @cache.py:110 - Wrote cache: /var/lib/rhsm/cache/rhsm_icon.json
2016-08-30 22:59:20,766 [DEBUG] subscription-manager:32201:MainThread @utils.py:291 - Restarted virt-who
2016-08-30 22:59:20,772 [virtwho.main WARNING] MainProcess(31428):MainThread @executor.py:reload:326 - virt-who reload


2016-08-30 22:59:29,433 [virtwho.main INFO] MainProcess(31428):MainThread @main.py:main:180 - Reloading
2016-08-30 22:59:29,433 [virtwho.main DEBUG] MainProcess(31428):MainThread @executor.py:run:171 - Starting infinite loop with 60 seconds interval
2016-08-30 22:59:29,439 [virtwho.env_cmdline DEBUG] Xen-8(32205):MainThread @virt.py:run:364 - Virt backend 'env/cmdline' started
2016-08-30 22:59:29,442 [virtwho.env_cmdline DEBUG] Xen-8(32205):MainThread @xen.py:_prepare:44 - Logging into XEN pools https://10.73.131.183
2016-08-30 22:59:35,300 [virtwho.env_cmdline DEBUG] Xen-8(32205):MainThread @xen.py:login:54 - XEN pool login successful with user root
2016-08-30 22:59:46,094 [virtwho.env_cmdline DEBUG] Xen-8(32205):MainThread @xen.py:getHostGuestMapping:87 - Control Domain 269d9301-275c-4c3b-a9df-994ddf1656c2 is ignored
2016-08-30 22:59:49,865 [virtwho.env_cmdline DEBUG] Xen-8(32205):MainThread @xen.py:getHostGuestMapping:87 - Control Domain 2629c102-8f29-4817-b32f-aa7802afbbf5 is ignored
2016-08-30 22:59:49,866 [virtwho.env_cmdline DEBUG] Xen-8(32205):MainThread @virt.py:enqueue:357 - Report for config "env/cmdline" gathered, putting to queue for sending
2016-08-30 22:59:49,872 [virtwho.main DEBUG] MainProcess(31428):MainThread @subscriptionmanager.py:_connect:124 - Authenticating with certificate: /etc/pki/consumer/cert.pem
2016-08-30 22:59:49,873 [virtwho.env_cmdline ERROR] Xen-8(32205):MainThread @xen.py:_wait:158 - Waiting on XEN events failed: 
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/virtwho/virt/xen/xen.py", line 148, in _wait
    1.0)
  File "/usr/lib/python2.7/site-packages/virtwho/virt/xen/XenAPI.py", line 260, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/site-packages/virtwho/virt/xen/XenAPI.py", line 161, in xenapi_request
    result = _parse_result(getattr(self, methodname)(*full_params))
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1233, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1587, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/site-packages/virtwho/util.py", line 39, in request
    resp = requests.post(self._url, data=request_body, headers=headers, verify=False)
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 108, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 464, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', error(4, 'Interrupted system call'))
2016-08-30 22:59:58,914 [virtwho.main ERROR] MainProcess(31428):MainThread @main.py:_main:189 - Fatal error:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/virtwho/main.py", line 186, in _main
    result = executor.run()
  File "/usr/lib/python2.7/site-packages/virtwho/executor.py", line 256, in run
    self.send_report(report.config.name, report)
  File "/usr/lib/python2.7/site-packages/virtwho/executor.py", line 95, in send_report
    if self.send(report):
  File "/usr/lib/python2.7/site-packages/virtwho/executor.py", line 139, in send
    self._sendGuestAssociation(report)
  File "/usr/lib/python2.7/site-packages/virtwho/executor.py", line 166, in _sendGuestAssociation
    manager.hypervisorCheckIn(report, self.options)
  File "/usr/lib/python2.7/site-packages/virtwho/manager/subscriptionmanager/subscriptionmanager.py", line 171, in hypervisorCheckIn
    self._connect(report.config)
  File "/usr/lib/python2.7/site-packages/virtwho/manager/subscriptionmanager/subscriptionmanager.py", line 127, in _connect
    "Unable to read certificate, system is not registered or you are not root")
SubscriptionManagerUnregisteredError: Unable to read certificate, system is not registered or you are not root
2016-08-30 22:59:58,914 [virtwho.main INFO] MainProcess(31428):MainThread @main.py:_main:191 - Waiting for reload signal


Actual results:
virt-who reload with "ConnectionError: ('Connection aborted.', error(4, 'Interrupted system call'))" before track system has been unregistered.

Expected results:
It shouldn't show ConnectionError when reload virt-who.

Additional info:

Comment 1 Chris Snyder 2016-12-22 16:40:41 UTC
The fix here should be to output a more reasonable message when virt-who is reloaded and no longer registered. The issue is that for configurations that do not specify what credentials to use, virt-who will try to use the certs on the system if it is registered.


In this case we should print something more like the following to stderr:
"SubscriptionManagerUnregisteredError: Unable to read certificate, system is not registered or you are not root"

Comment 3 William Poteat 2020-04-13 18:52:17 UTC
 When debug is on, a stack trace is generated [as expected]. When debug is not on, then only the error message is shown:

"virtwho.manager.subscriptionmanager.subscriptionmanager.SubscriptionManagerUnregisteredError: Unable to read certificate, system is not registered or you are not root"

This is the intended behavior. If the registration happens between virt-who runs, the system returns to normal processing.