Bug 1986485

Summary: otopi uses deprecated API platform.linux_distribution which has been removed in Python 3.7 and later.
Product: [oVirt] otopi Reporter: Sandro Bonazzola <sbonazzo>
Component: GeneralAssignee: Sandro Bonazzola <sbonazzo>
Status: CLOSED CURRENTRELEASE QA Contact: Pavol Brilla <pbrilla>
Severity: high Docs Contact:
Priority: medium    
Version: masterCC: bugs, gdeolive, lsvaty, pbrilla
Target Milestone: ovirt-4.5.0Keywords: CodeChange, Regression
Target Release: 1.10.0Flags: sbonazzo: ovirt-4.5?
lsvaty: blocker-
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: otopi-1.10.0 Doc Type: Bug Fix
Doc Text:
Cause: removal of deprecated API in python 3.7 Consequence: OTOPI fails to install packages due to missing API for querying linux distribution on CentOS Stream 9 Fix: Result:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-03 06:46:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Integration RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1986335, 1990767, 2034313    

Description Sandro Bonazzola 2021-07-27 16:41:03 UTC
Description of problem:

+ cov_otopi otopi packager-install-testpackage2 ODEBUG/packagesAction=str:install ODEBUG/packages=str:testpackage2
+ otopi=otopi
+ name=packager-install-testpackage2
+ shift 2
+ OTOPI_DEBUG=1
+ OTOPI_COVERAGE=1
+ COVERAGE_PROCESS_START=/home/sbonazzo/otopi/automation/coverage.rc
++ mktemp -p /home/sbonazzo/otopi .coverage.XXXXXX
+ COVERAGE_FILE=/home/sbonazzo/otopi/.coverage.Lv85aO
+ otopi CORE/logFileNamePrefix=str:otopi-packager-install-testpackage2 ODEBUG/packagesAction=str:install ODEBUG/packages=str:testpackage2
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'platform' has no attribute 'linux_distribution'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'platform' has no attribute 'linux_distribution'
/usr/share/otopi/otopi-functions: line 47: [: : integer expression expected
Loading plugin group otopi
Loading plugin otopi:core (/usr/share/otopi/plugins/otopi/core)
Loading plugin otopi:dialog (/usr/share/otopi/plugins/otopi/dialog)
Loading plugin otopi:network (/usr/share/otopi/plugins/otopi/network)
***L:ERROR Internal error: module 'platform' has no attribute 'linux_distribution'
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/otopi/main.py", line 141, in execute
    self.context.loadPlugins()
  File "/usr/lib/python3.9/site-packages/otopi/context.py", line 803, in loadPlugins
    self._loadPluginGroups(plugindir, needgroups, loadedgroups)
  File "/usr/lib/python3.9/site-packages/otopi/context.py", line 112, in _loadPluginGroups
    self._loadPlugins(path, path, groupname)
  File "/usr/lib/python3.9/site-packages/otopi/context.py", line 69, in _loadPlugins
    self._loadPlugins(base, d, groupname)
  File "/usr/lib/python3.9/site-packages/otopi/context.py", line 95, in _loadPlugins
    util.loadModule(
  File "/usr/share/otopi/plugins/otopi/network/__init__.py", line 22, in createPlugins
    iptables.Plugin(context=context)
  File "/usr/share/otopi/plugins/otopi/network/iptables.py", line 36, in __init__
    self._distribution = platform.linux_distribution(
AttributeError: module 'platform' has no attribute 'linux_distribution'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/otopi/__main__.py", line 88, in main
    installer.execute()
  File "/usr/lib/python3.9/site-packages/otopi/main.py", line 143, in execute
    util.raiseExceptionInformation(
  File "/usr/lib/python3.9/site-packages/otopi/util.py", line 85, in raiseExceptionInformation
    raise info[1].with_traceback(info[2])
  File "/usr/lib/python3.9/site-packages/otopi/main.py", line 141, in execute
    self.context.loadPlugins()
  File "/usr/lib/python3.9/site-packages/otopi/context.py", line 803, in loadPlugins
    self._loadPluginGroups(plugindir, needgroups, loadedgroups)
  File "/usr/lib/python3.9/site-packages/otopi/context.py", line 112, in _loadPluginGroups
    self._loadPlugins(path, path, groupname)
  File "/usr/lib/python3.9/site-packages/otopi/context.py", line 69, in _loadPlugins
    self._loadPlugins(base, d, groupname)
  File "/usr/lib/python3.9/site-packages/otopi/context.py", line 95, in _loadPlugins
    util.loadModule(
  File "/usr/share/otopi/plugins/otopi/network/__init__.py", line 22, in createPlugins
    iptables.Plugin(context=context)
  File "/usr/share/otopi/plugins/otopi/network/iptables.py", line 36, in __init__
    self._distribution = platform.linux_distribution(
otopi.main.PluginLoadException: module 'platform' has no attribute 'linux_distribution'



Steps to Reproduce:
1. Install CentOS Stream 9
2. run check-patch from https://gerrit.ovirt.org/c/otopi/+/115919
3.

Actual results: looks like platform module in Python 3.9 on CentOS Stream 9 is not providing anymore linux_distribution. We'll need to check if it's intended or file a bug on CentOS Stream for it.

Comment 1 RHEL Program Management 2021-07-27 16:41:12 UTC
This bug report has Keywords: Regression or TestBlocker.
Since no regressions or test blockers are allowed between releases, it is also being identified as a blocker for this release. Please resolve ASAP.

Comment 2 Sandro Bonazzola 2021-07-28 08:09:43 UTC
Confirmed being an intended change: https://docs.python.org/3.5/library/platform.html#platform.linux_distribution
was deprecated in Python 3.5 and removed in 3.7.

Comment 3 Sandro Bonazzola 2021-07-28 08:15:18 UTC
python3-distro is included in CentOS Stream 8 and derivatives and should be used instead of platform. More details: https://github.com/python-distro/distro

Comment 4 Pavol Brilla 2022-05-03 06:39:06 UTC
# yum deplist python3-otopi.noarch | grep distro
  dependency: python3-distro
   provider: python3-distro-1.4.0-2.module+el8.1.0+3334+5cb623d7.noarch
   provider: python3-distro-1.4.0-2.module+el8.1.0+3334+5cb623d7.noarch


Installed Packages
python3-otopi.noarch     1.10.0-1.el8ev

Comment 5 Sandro Bonazzola 2022-05-03 06:46:19 UTC
This bugzilla is included in oVirt 4.5.0 release, published on April 20th 2022.

Since the problem described in this bug report should be resolved in oVirt 4.5.0 release, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.