Merge "Use oslo.utils implementation to compare versions"

This commit is contained in:
Zuul 2024-10-05 13:22:40 +00:00 committed by Gerrit Code Review
commit 27b0679861
2 changed files with 9 additions and 16 deletions

View File

@ -55,7 +55,6 @@ zake =
zake>=0.1.6 # Apache-2.0
redis =
redis>=4.0.0 # MIT
packaging>=20.4.0 # Apache-2.0
postgresql =
psycopg2>=2.5 # LGPL/ZPL
mysql =

View File

@ -22,7 +22,7 @@ import threading
from oslo_utils import encodeutils
from oslo_utils import netutils
from oslo_utils import strutils
from packaging import version
from oslo_utils import versionutils
import redis
from redis import exceptions
from redis import sentinel
@ -219,7 +219,7 @@ class RedisDriver(coordination.CoordinationDriverCachedRunWatchers,
enum member(s) that can be used to interogate how this driver works.
"""
MIN_VERSION = version.Version("2.6.0")
MIN_VERSION = "2.6.0"
"""
The min redis version that this driver requires to operate with...
"""
@ -393,22 +393,16 @@ return 1
self._server_info = {}
self._scripts = {}
def _check_fetch_redis_version(self, geq_version, not_existent=True):
if isinstance(geq_version, str):
desired_version = version.Version(geq_version)
elif isinstance(geq_version, version.Version):
desired_version = geq_version
else:
raise TypeError("Version check expects a string/version type")
def _check_fetch_redis_version(self, desired_version, not_existent=True):
try:
redis_version = version.Version(self._server_info['redis_version'])
redis_version = self._server_info['redis_version']
except KeyError:
return (not_existent, None)
else:
if redis_version < desired_version:
return (False, redis_version)
else:
return (True, redis_version)
if versionutils.is_compatible(desired_version, redis_version,
same_major=False):
return (True, redis_version)
return (False, redis_version)
@property
def namespace(self):