Bug 1631339
Summary: | subscription-manager and python-3.7 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Rob Sanders <rob> | ||||||||
Component: | subscription-manager | Assignee: | candlepin-bugs | ||||||||
Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> | ||||||||
Severity: | high | Docs Contact: | |||||||||
Priority: | high | ||||||||||
Version: | 29 | CC: | alikins, awood, bkearney, bshephar, csnyder, fvzwieten, jburck, jhnidek, khowell, lau18, ricferna, rob, sgraf, wheeler | ||||||||
Target Milestone: | --- | Keywords: | Triaged | ||||||||
Target Release: | --- | ||||||||||
Hardware: | Unspecified | ||||||||||
OS: | Unspecified | ||||||||||
Whiteboard: | |||||||||||
Fixed In Version: | subscription-manager-1.25.5-1.fc30 subscription-manager-1.25.9-1.fc29 | Doc Type: | If docs needed, set a value | ||||||||
Doc Text: | Story Points: | --- | |||||||||
Clone Of: | Environment: | ||||||||||
Last Closed: | 2019-05-21 01:09:19 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
Rob Sanders
2018-09-20 11:31:28 UTC
*** Bug 1636654 has been marked as a duplicate of this bug. *** Rob, would you like to submit a PR for this? https://github.com/candlepin/subscription-manager. We ask that the commit message start with the bug number (ex. 1631339: Fix os.errno issue). Would also accept a patch that git can apply via git am. We'd like to recognize your contribution by having a commit/changelog entry if you'd like. Hi Kevin, As per your request PR #1953 is now ready. When I do this: subscription-manager register: Username: <name> Password: <...> module 'os' has no attribute 'errno' This is on a subscription-manager on Fedora 29 that has already above fix # subscription_manager]# rpm -qa | grep -i subscription subscription-manager-rhsm-certificates-1.24.2-1.fc29.x86_64 dnf-plugin-subscription-manager-1.24.2-1.fc29.x86_64 python3-subscription-manager-rhsm-1.24.2-1.fc29.x86_64 subscription-manager-1.24.2-1.fc29.x86_64 I also saw the it, module 'os' has no attribute 'errno', while registering. rhsm.log showed: 2018-12-18 10:24:20,189 [INFO] subscription-manager:1871:MainThread @connection.py:917 - Connection built: host=subscription.rhsm.redhat.com port=443 handler=/subscription auth=basic username=; 2018-12-18 10:24:20,190 [ERROR] subscription-manager:1871:MainThread @managercli.py:190 - Error during registration: module 'os' has no attribute 'errno' 2018-12-18 10:24:20,190 [ERROR] subscription-manager:1871:MainThread @managercli.py:191 - module 'os' has no attribute 'errno' Traceback (most recent call last): File "/usr/lib/python3.7/site-packages/syspurpose/utils.py", line 51, in create_dir os.makedirs(path, mode=0o755) File "/usr/lib64/python3.7/os.py", line 221, in makedirs mkdir(name, mode) FileExistsError: [Errno 17] File exists: '/etc/rhsm/syspurpose' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib64/python3.7/site-packages/subscription_manager/managercli.py", line 1273, in _do_command syspurpose = syspurposelib.read_syspurpose() File "/usr/lib64/python3.7/site-packages/subscription_manager/syspurposelib.py", line 234, in read_syspurpose syspurpose = SyspurposeStore.read(USER_SYSPURPOSE).contents File "/usr/lib/python3.7/site-packages/syspurpose/files.py", line 187, in read new_store.create() File "/usr/lib/python3.7/site-packages/syspurpose/files.py", line 78, in create return create_dir(os.path.dirname(self.path)) or \ File "/usr/lib/python3.7/site-packages/syspurpose/utils.py", line 53, in create_dir if e.errno == os.errno.EEXIST: AttributeError: module 'os' has no attribute 'errno' 2018-12-18 10:33:01,547 [INFO] yum:1890:MainThread @connection.py:917 - Connection built: host=subscription.rhsm.redhat.com port=443 handler=/subscription auth=identity_cert ca_dir=/etc/rhsm/ca/ insecure=False Looks like this is happening again on Fedora 29.. I made similar changes to: /usr/lib/python3.7/site-packages/syspurpose/utils.py and /usr/lib/python3.7/site-packages/syspurpose/files.py import errno and :%s/os.errno/errno/g This has got me past that error, but now I'm getting: sudo subscription-manager register Registering to: satellite.bne-home.net:443/rhsm Username: admin Password: Environment: Library 'dict' object has no attribute 'has_key' Looks like this is raised when it tries to call: if not conduit.facts.has_key('network.fqdn'): conduit.facts['network.fqdn'] = socket.getfqdn() from /usr/share/rhsm-plugins/fqdn.py I checked to make sure that socket.getfqdn() worked on it's own, which it did. So I just did this: import socket from subscription_manager.base_plugin import SubManPlugin requires_api_version = "1.0" class FactsPlugin(SubManPlugin): name = 'fqdn fact' def post_facts_collection_hook(self, conduit): try: if not conduit.facts.has_key('network.fqdn'): conduit.facts['network.fqdn'] = socket.getfqdn() except AttributeError as e: log.debug("Attribute error in collecting facts: %s" % e) conduit.facts['network.fqdn'] = socket.getfqdn() This allows me to register the system. Probably not the greatest fix for the problem. Probably would help to identify why it couldn't get it in the first place. But my python skillz are limited and this got me out of trouble. Hopefully it provides enough information for a better solution. :) Sorry, that log.debug section didn't actually log anything for me so I removed it and just did the try, except without logging anything. As I said, amateur Python skillz. The working one looks like this:
import socket
from subscription_manager.base_plugin import SubManPlugin
requires_api_version = "1.0"
class FactsPlugin(SubManPlugin):
name = 'fqdn fact'
def post_facts_collection_hook(self, conduit):
try:
if not conduit.facts.has_key('network.fqdn'):
conduit.facts['network.fqdn'] = socket.getfqdn()
except AttributeError as e:
conduit.facts['network.fqdn'] = socket.getfqdn()
And I verified that the fact is actually available in subscription-manager as well
sudo subscription-manager facts | grep fqdn
network.fqdn: fedora-desktop.bne-home.net
python3.7
Python 3.7.1 (default, Nov 23 2018, 10:01:49)
[GCC 8.2.1 20181105 (Red Hat 8.2.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.getfqdn()
'fedora-desktop.bne-home.net'
Current master branch of subscription-manager does not include any 'os.errno'. It was replaced by 'errno' module. 'subscription-manager facts | grep fqdn' works for me too. Fedora 29 is still listing 1.24.2-1 as the latest version, so this is still problematic when installing subscription-manager through yum. I've also edited the files: - /usr/lib/python3.7/site-packages/syspurpose/utils.py - /usr/lib/python3.7/site-packages/syspurpose/files.py To get rid of the "module 'os' has no attribute 'errno'" error. I'm attaching these files if anyone needs them in the future. I've looked at the repo and it seems that it's already been corrected. It's just a matter of applying the fix for F29. [1] https://github.com/candlepin/subscription-manager/tree/master/syspurpose/src/syspurpose Cheers! Created attachment 1536711 [details]
utils.py fixed
/usr/lib/python3.7/site-packages/syspurpose/utils.py fixed
Created attachment 1536713 [details]
files.py fixed
/usr/lib/python3.7/site-packages/syspurpose/files.py with the fixes
subscription-manager-1.25.5-1.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2019-6663f52736 subscription-manager-1.25.5-1.fc29 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-3928f88562 subscription-manager-1.25.5-1.fc30 has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-10f8c3b13d subscription-manager-1.25.5-1.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-10f8c3b13d subscription-manager-1.25.5-1.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-6663f52736 subscription-manager-1.25.5-1.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-3928f88562 subscription-manager-1.25.5-1.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report. FEDORA-2019-3928f88562 has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-3928f88562 subscription-manager-1.25.9-1.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-3928f88562 subscription-manager-1.25.9-1.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report. |