Virt-who service fails to start on Red Hat Satellite 6.x with a 'ImportError: cannot import name DependencyWarning' error
Environment
- Red Hat Satellite 6.x
Issue
Virt-who service fails to start on Red Hat Satellite 6.x with the following error:
# systemctl status virt-who.service
● virt-who.service - Daemon for reporting virtual guest IDs to subscription-manager
Loaded: loaded (/usr/lib/systemd/system/virt-who.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2022-05-10 13:32:03 EET; 39min ago
Process: 69849 ExecStart=/usr/bin/virt-who (code=exited, status=1/FAILURE)
Main PID: 69849 (code=exited, status=1/FAILURE)
May 10 13:32:03 satellite.example.com virt-who[69849]: import virtwho.main
May 10 13:32:03 satellite.example.com virt-who[69849]: File "/usr/lib/python2.7/site-packages/virtwho/main...le>
May 10 13:32:03 satellite.example.com virt-who[69849]: import requests
May 10 13:32:03 satellite.example.com virt-who[69849]: File "/usr/lib/python2.7/site-packages/requests/__i...le>
May 10 13:32:03 satellite.example.com virt-who[69849]: from urllib3.exceptions import DependencyWarning
May 10 13:32:03 satellite.example.com virt-who[69849]: ImportError: cannot import name DependencyWarning
May 10 13:32:03 satellite.example.com systemd[1]: virt-who.service: main process exited, code=exited, sta...LURE
May 10 13:32:03 satellite.example.com systemd[1]: Failed to start Daemon for reporting virtual guest IDs ...ger.
May 10 13:32:03 satellite.example.com systemd[1]: Unit virt-who.service entered failed state.
May 10 13:32:03 satellite.example.com systemd[1]: virt-who.service failed.
Hint: Some lines were ellipsized, use -l to show in full
Resolution
Follow the procedure described in the Diagnostic Steps section. Then based on the outcome, apply the following procedure:
- Execute the following commands on the Satellite server:
# rpm -e --nodeps python2-urllib3
# yum --disableplugin=foreman-protector install python-urllib3
# rpm -e --nodeps python2-chardet
# yum --disableplugin=foreman-protector install python-chardet
# rpm -e --nodeps python2-requests
# yum --disableplugin=foreman-protector install python-requests
- Verify that the virt-who service can now start successfully:
# systemctl start virt-who.service
# systemctl status virt-who.service
For more KB articles/solutions related to Virt-who and Virtual Datacenter (VDC) Subscriptions Issues, please refer to the Consolidated Troubleshooting Article for Virt-who and Virtual Datacenter (VDC) Subscriptions Issues
Diagnostic Steps
- Run the following commands on the Satellite server:
# service virt-who stop
# virt-who -dp &> /tmp/mappings.txt
# service virt-who start
- Check the contents of the mappings.txt file. If you see a backtrace like this one:
/usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.10.2) or chardet (3.0.4) doesn't match a supported version!
RequestsDependencyWarning)
Traceback (most recent call last):
File "/bin/virt-who", line 9, in <module>
load_entry_point('virt-who==0.28.10', 'console_scripts', 'virt-who')()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2355, in load
return self.resolve()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2361, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python2.7/site-packages/virtwho/__main__.py", line 8, in <module>
import virtwho.main
File "/usr/lib/python2.7/site-packages/virtwho/main.py", line 26, in <module>
import requests
File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 94, in <module>
from urllib3.exceptions import DependencyWarning
ImportError: cannot import name DependencyWarning
run the following commands on the Satellite server:
# rpm -qa | grep -i urllib3*
# rpm -qa | grep -i chardet
# rpm -qa | grep requests
The outputs from these 3 commands should be as follows:
# rpm -qa | grep -i urllib3*
python3-urllib3-1.25.11-1.el7pc.noarch
python-urllib3-1.10.2-7.el7.noarch
# rpm -qa | grep -i chardet
python3-chardet-3.0.4-10.el7ar.noarch
python-chardet-2.2.1-3.el7.noarch
# rpm -qa | grep requests
python3-requests-2.24.0-1.el7pc.noarch
python-requests-2.6.0-10.el7.noarch
respectively.
- If the outputs from the two commands are something like:
# rpm -qa | grep -i urllib3*
python2-urllib3-1.24.3-2.el7.noarch
python3-urllib3-1.25.11-1.el7pc.noarch
# rpm -qa | grep -i chardet
python2-chardet-3.0.4-7.el7ost.noarch
python3-chardet-3.0.4-10.el7ar.noarch
# rpm -qa | grep requests
python3-requests-2.24.0-1.el7pc.noarch
python2-requests-2.19.1-6.el7.noarch
then apply the procedure in the Resolution section.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.