Remove use of pkg_resources

Use of this library has significant performance implications. While
we're probably not too badly affected, we don't actually need to use it
here. The 'parse_version' utility it exposes is intended to parse
PEP440-compliant version identifiers, not the simple microversions
placement uses, which the 'microversion_parse' library can competently
parse for us.

Change-Id: I9b7281caec6fa53600dea316492d052787cf799b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2020-07-13 11:41:34 +01:00 committed by Stephen Finucane
parent de65131f92
commit 8133092907
2 changed files with 11 additions and 10 deletions

View File

@ -21,10 +21,10 @@ import sys
import traceback
from keystoneauth1 import exceptions as ks_exc
import microversion_parse
from oslo_config import cfg
from oslo_upgradecheck import common_checks
from oslo_upgradecheck import upgradecheck
import pkg_resources
import sqlalchemy as sa
from sqlalchemy import func as sqlfunc
@ -175,9 +175,9 @@ class UpgradeCommands(upgradecheck.UpgradeCommands):
try:
# TODO(efried): Use ksa's version filtering in _placement_get
versions = self._placement_get("/")
max_version = pkg_resources.parse_version(
max_version = microversion_parse.parse_version_string(
versions["versions"][0]["max_version"])
needs_version = pkg_resources.parse_version(
needs_version = microversion_parse.parse_version_string(
MIN_PLACEMENT_MICROVERSION)
if max_version < needs_version:
msg = (_('Placement API version %(needed)s needed, '

View File

@ -14,11 +14,11 @@
import copy
import ddt
from keystoneauth1 import exceptions as kse
import microversion_parse
import mock
import os_resource_classes as orc
import os_traits as ot
from oslo_utils.fixture import uuidsentinel as uuids
import pkg_resources
from nova.cmd import status
from nova.compute import provider_tree
@ -39,9 +39,6 @@ from nova.tests.functional import fixtures as func_fixtures
CONF = conf.CONF
CMD_STATUS_MIN_MICROVERSION = pkg_resources.parse_version(
status.MIN_PLACEMENT_MICROVERSION)
class VersionCheckingReportClient(report.SchedulerReportClient):
"""This wrapper around SchedulerReportClient checks microversions for
@ -57,14 +54,18 @@ class VersionCheckingReportClient(report.SchedulerReportClient):
if not microversion:
return
seen_microversion = pkg_resources.parse_version(microversion)
if seen_microversion > CMD_STATUS_MIN_MICROVERSION:
min_microversion = microversion_parse.parse_version_string(
status.MIN_PLACEMENT_MICROVERSION)
got_microversion = microversion_parse.parse_version_string(
microversion)
if got_microversion > min_microversion:
raise ValueError(
"Report client is using microversion %s, but nova.cmd.status "
"is only requiring %s. See "
"I4369f7fb1453e896864222fa407437982be8f6b5 for an example of "
"how to bump the minimum requirement." %
(microversion, status.MIN_PLACEMENT_MICROVERSION))
(got_microversion, min_microversion)
)
def get(self, *args, **kwargs):
self._check_microversion(kwargs)