From 4b8a53f4c123ddaabe85f16c593c022985574f23 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 30 Sep 2024 20:16:27 +0900 Subject: [PATCH] Switch back to built-in md5 function hashlib.md5 always supports usedforsecurity argument in Python 3.9 and later. The method in oslo.utils is being deprecated[1]. [1] https://review.opendev.org/c/openstack/oslo.utils/+/930879 Change-Id: I8b426c2803a08c15e078b6f6ea4b462ac3a81f3b --- aodh/coordination.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aodh/coordination.py b/aodh/coordination.py index ab88d1ad8..7c8e8ab95 100644 --- a/aodh/coordination.py +++ b/aodh/coordination.py @@ -13,12 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. import bisect +import hashlib import struct from oslo_config import cfg from oslo_log import log from oslo_utils import encodeutils -from oslo_utils.secretutils import md5 from oslo_utils import uuidutils import tenacity import tooz.coordination @@ -79,7 +79,8 @@ class HashRing(object): @staticmethod def _hash(key): return struct.unpack_from( - '>I', md5(str(key).encode(), usedforsecurity=False).digest())[0] + '>I', + hashlib.md5(str(key).encode(), usedforsecurity=False).digest())[0] def _get_position_on_ring(self, key): hashed_key = self._hash(key)