-
Bug
-
Resolution: Done
-
Undefined
-
None
-
None
-
None
-
False
-
-
False
Hi,
This issue duplicated the one I opened in launchpad, https://bugs.launchpad.net/nova/+bug/2069333, as from some offline discussions, it seems the problem doesn't exist in the master. I'm wondering if it may be caused by the the version of `importlib_metadata` in RDO.
I recently upgraded an Antelope Magnum server to Caracal. After the upgrade, I have not been able to run `magnum-db-manage` because of an exception in magnum/_init_ when retrieving the Magnum version, the value returned being None. This happens on an EL9.4 machine using Caracal RPMs from RDO repository (repository from one week ago, June 7).
Steps to reproduce
==================
- Run `nova-db-manage version` (or magnum-api) on an EL9.4 machine
Expected result
===============
The DB version number, something like `Current DB revision is c0f832afc4fd`
Actual result
=============
I get the following exception:
```
File "/usr/bin/magnum-db-manage", line 5, in <module>
from magnum.cmd.db_manage import main
File "/usr/lib/python3.9/site-packages/magnum/_init_.py", line 18, in <module>
_version_ = pbr.version.VersionInfo(
File "/usr/lib/python3.9/site-packages/pbr/version.py", line 505, in version_string
return self.semantic_version().brief_string()
File "/usr/lib/python3.9/site-packages/pbr/version.py", line 498, in semantic_version
self._semantic = self._get_version_from_importlib_metadata()
File "/usr/lib/python3.9/site-packages/pbr/version.py", line 483, in _get_version_from_importlib_metadata
return SemanticVersion.from_pip_string(result_string)
File "/usr/lib/python3.9/site-packages/pbr/version.py", line 156, in from_pip_string
return klass._from_pip_string_unsafe(version_string)
File "/usr/lib/python3.9/site-packages/pbr/version.py", line 163, in _from_pip_string_unsafe
version_string = version_string.lstrip('vV')
AttributeError: 'NoneType' object has no attribute 'lstrip'
```
After looking a little bit at the problem, I found that the culprit is probably module importlib.metadata provided by python3-importlib-metadata-6.8.0-1.el9s.noarch (that has been installed from RDO repository mirror, the last version today). Because of a problem in this module, the returned value for magnum from importlib.metadata.distribution() called by pbr.version.VersionInfo() (itself called by magnum/_init_ as shown by the traceback given in my first message) is None instead of a string.
The following code (copied from pbr.version) allows to demonstrate the problem:
```
#!/usr/bin/python
from importlib import metadata as importlib_metadata
for package in ['magnum']:
distribution = importlib_metadata.distribution(package)
result_string = distribution.version
print("package", package, "result_string=", result_string)
```
If run on an Antelope machine it works fine. If run on a Caracal machine it returns None.
Environment
===========
```
python3-pbr-5.11.1-1.el9s.noarch
python3-importlib-metadata-6.8.0-1.el9s.noarch
python3-magnumclient-4.4.0-1.el9s.noarch
python3-magnum-18.0.0-1.el9s.noarch
openstack-magnum-common-18.0.0-1.el9s.noarch
openstack-magnum-api-18.0.0-1.el9s.noarch
openstack-magnum-conductor-18.0.0-1.el9s.noarch
```