Remove Python 3.8 support

Python 3.8 is no longer part of the tested runtimes for 2024.2[1]
because its EOL is coming soon.

Also replace the deprecated md5 wrapper from oslo.utils.

[1] https://governance.openstack.org/tc/reference/runtimes/2024.2.html

Change-Id: I655bc426213694251a855a54633a10276549c5fe
This commit is contained in:
Takashi Kajinami 2024-10-16 11:52:52 +09:00
parent 53b085b20e
commit de0a78f908
4 changed files with 11 additions and 17 deletions

View File

@ -0,0 +1,5 @@
---
upgrade:
- |
Support for Python 3.8 has been removed. Now the minimum python version
supported is 3.9 .

View File

@ -6,7 +6,7 @@ summary = Coordination library for distributed systems.
description_file = README.rst
license = Apache-2
home_page = https://docs.openstack.org/tooz/latest/
python_requires = >=3.8
python_requires = >=3.9
classifier =
Environment :: OpenStack
Intended Audience :: Developers
@ -15,7 +15,6 @@ classifier =
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11

View File

@ -16,8 +16,6 @@
import bisect
import hashlib
from oslo_utils.secretutils import md5
import tooz
from tooz import utils
@ -83,7 +81,7 @@ class HashRing(object):
for node in nodes:
key = utils.to_binary(node, 'utf-8')
if self._hash_function == 'md5':
key_hash = md5(key, usedforsecurity=False)
key_hash = hashlib.md5(key, usedforsecurity=False)
else:
key_hash = hashlib.new(self._hash_function, key)
for r in range(self._partition_number * weight):
@ -108,7 +106,7 @@ class HashRing(object):
key = utils.to_binary(node, 'utf-8')
if self._hash_function == 'md5':
key_hash = md5(key, usedforsecurity=False)
key_hash = hashlib.md5(key, usedforsecurity=False)
else:
key_hash = hashlib.new(self._hash_function, key)
for r in range(self._partition_number * weight):
@ -123,7 +121,8 @@ class HashRing(object):
def _get_partition(self, data):
if self._hash_function == 'md5':
hashed_key = self._hash2int(md5(data, usedforsecurity=False))
hashed_key = self._hash2int(
hashlib.md5(data, usedforsecurity=False))
else:
hashed_key = self._hash2int(
hashlib.new(self._hash_function, data))

View File

@ -31,12 +31,6 @@ class HashRingTestCase(testcase.TestCase):
# fake -> foo, bar, baz
# fake-again -> bar, baz, foo
try:
_ = hashlib.md5(usedforsecurity=False)
_fips_enabled = True
except TypeError:
_fips_enabled = False
@mock.patch.object(hashlib, 'md5', autospec=True)
def test_hash2int_returns_int(self, mock_md5):
r1 = 32 * 'a'
@ -50,10 +44,7 @@ class HashRingTestCase(testcase.TestCase):
self.assertIn(int(r1, 16), ring._ring)
self.assertIn(int(r2, 16), ring._ring)
if self._fips_enabled:
mock_md5.assert_called_with(mock.ANY, usedforsecurity=False)
else:
mock_md5.assert_called_with(mock.ANY)
def test_create_ring(self):
nodes = {'foo', 'bar'}