Bug 1995465

Summary: rhsm.service fails to start with Python AttributeError
Product: [Fedora] Fedora Reporter: Marius Vollmer <mvollmer>
Component: subscription-managerAssignee: Jiri Hnidek <jhnidek>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 35CC: alikins, awood, batinich1, bkearney, carl, csnyder, jhnidek, jpazdziora, kahara, ktordeur, matthew.lesieur, maxwell, mhjacks, mhofmann, praiskup, ptoscano, riek, wpoteat
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-02-21 18:07:11 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 Marius Vollmer 2021-08-19 08:27:03 UTC
Description of problem:

Starting the rhsm.service fails with this output:

Aug 19 08:24:41 fedora-35-127-0-0-2-2201 systemd[1]: Starting RHSM dbus service...
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]: Traceback (most recent call last):
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "/usr/libexec/rhsm-service", line 33, in <module>
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:     sys.exit(load_entry_point('subscription-manager==1.29.18', 'console_scripts', 'rhsm-service')())
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "/usr/libexec/rhsm-service", line 25, in importlib_load_entry_point
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:     return next(matches).load()
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "/usr/lib64/python3.10/importlib/metadata/__init__.py", line 162, in load
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:     module = import_module(match.group('module'))
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "/usr/lib64/python3.10/importlib/__init__.py", line 126, in import_module
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:     return _bootstrap._gcd_import(name[level:], package, level)
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "/usr/lib64/python3.10/site-packages/subscription_manager/scripts/rhsm_service.py", line 35, in <module>
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:     from rhsmlib.dbus import service_wrapper
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "/usr/lib64/python3.10/site-packages/rhsmlib/dbus/service_wrapper.py", line 23, in <module>
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:     from rhsmlib.dbus import server
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "/usr/lib64/python3.10/site-packages/rhsmlib/dbus/server.py", line 28, in <module>
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:     from rhsmlib.services import config
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:   File "/usr/lib64/python3.10/site-packages/rhsmlib/services/config.py", line 21, in <module>
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]:     class Config(collections.MutableMapping):
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 rhsm-service[1824]: AttributeError: module 'collections' has no attribute 'MutableMapping'
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 systemd[1]: rhsm.service: Main process exited, code=exited, status=1/FAILURE
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 systemd[1]: rhsm.service: Failed with result 'exit-code'.
Aug 19 08:24:41 fedora-35-127-0-0-2-2201 systemd[1]: Failed to start RHSM dbus service.

Version-Release number of selected component (if applicable):
subscription-manager-1.29.18-2.fc35.x86_64

How reproducible:
Always

Steps to Reproduce:
1. systemctl start rhsm.service

Comment 1 Marius Vollmer 2021-08-23 08:31:07 UTC
I think this might be caused by Python 3.10.  Older versions produce a warning that 3.10 will break "collections.MutableMapping":

$ python
Python 3.9.6 (default, Jul 16 2021, 00:00:00) 
[GCC 11.1.1 20210531 (Red Hat 11.1.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import collections
>>> collections.MutableMapping
<stdin>:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
<class 'collections.abc.MutableMapping'>
>>>

Comment 2 Martin Jackson 2021-11-02 15:45:56 UTC
I see this behavior in f35 as released. The same problem seems to cause subscription-manager to crash on invocation:

# subscription-manager refresh
Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 33, in <module>
    sys.exit(load_entry_point('subscription-manager==1.29.18', 'console_scripts', 'subscription-manager')())
  File "/usr/sbin/subscription-manager", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib64/python3.10/importlib/metadata/__init__.py", line 162, in load
    module = import_module(match.group('module'))
  File "/usr/lib64/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib64/python3.10/site-packages/subscription_manager/scripts/subscription_manager.py", line 64, in <module>
    from subscription_manager.injectioninit import init_dep_injection
  File "/usr/lib64/python3.10/site-packages/subscription_manager/injectioninit.py", line 20, in <module>
    from subscription_manager.cache import ProductStatusCache, EntitlementStatusCache, \
  File "/usr/lib64/python3.10/site-packages/subscription_manager/cache.py", line 32, in <module>
    from rhsm.profile import get_profile
  File "/usr/lib64/python3.10/site-packages/rhsm/profile.py", line 24, in <module>
    from cloud_what import provider
  File "/usr/lib64/python3.10/site-packages/cloud_what/provider.py", line 27, in <module>
    from rhsmlib.facts.host_collector import HostCollector
  File "/usr/lib64/python3.10/site-packages/rhsmlib/facts/host_collector.py", line 20, in <module>
    from rhsmlib.facts import cleanup
  File "/usr/lib64/python3.10/site-packages/rhsmlib/facts/cleanup.py", line 18, in <module>
    from rhsmlib.facts import collector
  File "/usr/lib64/python3.10/site-packages/rhsmlib/facts/collector.py", line 20, in <module>
    from rhsmlib.facts import collection
  File "/usr/lib64/python3.10/site-packages/rhsmlib/facts/collection.py", line 23, in <module>
    class FactsDict(collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'

Comment 3 Pino Toscano 2021-11-04 06:36:40 UTC
*** Bug 2017195 has been marked as a duplicate of this bug. ***

Comment 4 Pino Toscano 2021-11-04 06:40:55 UTC
This was already fixed upstream with:
https://github.com/candlepin/subscription-manager/pull/2753

There was no upstream release since then though.

Comment 5 Rehana 2021-11-23 14:33:13 UTC
*** Bug 2022850 has been marked as a duplicate of this bug. ***

Comment 6 Pavel Raiskup 2021-12-14 19:03:00 UTC
I can see there's already F35 build:
https://koji.fedoraproject.org/koji/buildinfo?buildID=1858632

Can a new Bodhi update be created?

Tested by:

$ sudo dnf update --disableplugin product-id \
                  --disableplugin=subscription-manager \
                  --disableplugin=upload-profile \
https://kojipkgs.fedoraproject.org//packages/subscription-manager/1.29.21/1.fc35/x86_64/python3-subscription-manager-rhsm-1.29.21-1.fc35.x86_64.rpm \
https://kojipkgs.fedoraproject.org//packages/subscription-manager/1.29.21/1.fc35/x86_64/python3-cloud-what-1.29.21-1.fc35.x86_64.rpm \
https://kojipkgs.fedoraproject.org//packages/subscription-manager/1.29.21/1.fc35/x86_64/subscription-manager-rhsm-certificates-1.29.21-1.fc35.x86_64.rpm \
https://kojipkgs.fedoraproject.org//packages/subscription-manager/1.29.21/1.fc35/x86_64/subscription-manager-1.29.21-1.fc35.x86_64.rpm \
https://kojipkgs.fedoraproject.org//packages/subscription-manager/1.29.21/1.fc35/x86_64/libdnf-plugin-subscription-manager-1.29.21-1.fc35.x86_64.rpm

(note you have to --disableplugin=... to make dnf work again for normal operations)

This blocks Fedora Copr migration to the Fedora 35 machines, where we plan to build
EPEL 8 packages against RHEL 8 using subscribed Fedora.  Subscription-manager will be
needed on Fedora since CentOS 8 goes EOL soon, and many people will likely try to build
against RHEL using Mock: https://pagure.io/epel/issue/133

Comment 7 Pavel Raiskup 2022-01-04 09:52:34 UTC
Ping, the built version 1.29.21-1 fixes the issue, we just need the Bodhi update.
Installing the current subscription-manager (1.29.18) into F35 totally breaks DNF stack,
so sending the update can not cause any more harm than that.

Comment 8 Chris Snyder 2022-01-06 16:09:53 UTC
Please see this update for when the fix for this will come to f35: https://bodhi.fedoraproject.org/updates/FEDORA-2022-1da95f09ca

Comment 9 Pino Toscano 2022-02-21 18:07:11 UTC
The update was pushed to stable for f35 some days ago, hence closing.

Comment 10 Pino Toscano 2022-02-21 18:08:18 UTC
*** Bug 2034836 has been marked as a duplicate of this bug. ***