From 88c2fd905af78702ab64a185ed7181c3632fcb86 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 25 Jun 2024 11:18:49 +0900 Subject: [PATCH] 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. [1] https://governance.openstack.org/tc/reference/runtimes/2024.2.html Change-Id: I3e9ba41b542ea6309a7415337f60fd37bc9adebc --- aodh/api/controllers/v2/alarms.py | 16 +++------------- aodh/evaluator/__init__.py | 14 ++------------ aodh/tests/unit/evaluator/test_gnocchi.py | 18 +++--------------- .../drop-python-3-8-24f35246e92cf9af.yaml | 5 +++++ requirements.txt | 3 +-- setup.cfg | 3 +-- 6 files changed, 15 insertions(+), 44 deletions(-) create mode 100644 releasenotes/notes/drop-python-3-8-24f35246e92cf9af.yaml diff --git a/aodh/api/controllers/v2/alarms.py b/aodh/api/controllers/v2/alarms.py index 658d9b434..11d51235c 100644 --- a/aodh/api/controllers/v2/alarms.py +++ b/aodh/api/controllers/v2/alarms.py @@ -21,6 +21,7 @@ import datetime import itertools import json +import zoneinfo import croniter from oslo_config import cfg @@ -36,14 +37,6 @@ import wsme from wsme import types as wtypes import wsmeext.pecan as wsme_pecan -try: - import zoneinfo -except ImportError: - # zoneinfo is available in Python >= 3.9 - import pytz - import pytz.exceptions - zoneinfo = None - import aodh from aodh.api.controllers.v2 import base from aodh.api.controllers.v2 import utils as v2_utils @@ -182,12 +175,9 @@ class AlarmTimeConstraint(base.Base): @staticmethod def validate(tc): if tc.timezone: - checker = zoneinfo.ZoneInfo if zoneinfo else pytz.timezone - exc = (zoneinfo.ZoneInfoNotFoundError if zoneinfo else - pytz.exceptions.UnknownTimeZoneError) try: - checker(tc.timezone) - except exc: + zoneinfo.ZoneInfo(tc.timezone) + except zoneinfo.ZoneInfoNotFoundError: raise base.ClientSideError(_("Timezone %s is not valid") % tc.timezone) return tc diff --git a/aodh/evaluator/__init__.py b/aodh/evaluator/__init__.py index c833450f7..c1938e6be 100644 --- a/aodh/evaluator/__init__.py +++ b/aodh/evaluator/__init__.py @@ -18,6 +18,7 @@ import abc import datetime import json import threading +import zoneinfo from concurrent import futures import cotyledon @@ -29,13 +30,6 @@ from oslo_utils import timeutils from oslo_utils import uuidutils from stevedore import extension -try: - import zoneinfo -except ImportError: - # zoneinfo is available in Python >= 3.9 - import pytz - zoneinfo = None - import aodh from aodh import coordination from aodh import keystone_client @@ -156,11 +150,7 @@ class Evaluator(object, metaclass=abc.ABCMeta): now_utc = timeutils.utcnow().replace(tzinfo=datetime.timezone.utc) for tc in alarm.time_constraints: - if zoneinfo: - tz = (zoneinfo.ZoneInfo(tc['timezone']) - if tc['timezone'] else None) - else: - tz = pytz.timezone(tc['timezone']) if tc['timezone'] else None + tz = zoneinfo.ZoneInfo(tc['timezone']) if tc['timezone'] else None now_tz = now_utc.astimezone(tz) if tz else now_utc start_cron = croniter.croniter(tc['start'], now_tz) if cls._is_exact_match(start_cron, now_tz): diff --git a/aodh/tests/unit/evaluator/test_gnocchi.py b/aodh/tests/unit/evaluator/test_gnocchi.py index 838757f36..024493f3d 100644 --- a/aodh/tests/unit/evaluator/test_gnocchi.py +++ b/aodh/tests/unit/evaluator/test_gnocchi.py @@ -18,18 +18,12 @@ import datetime import fixtures import json from unittest import mock +import zoneinfo from gnocchiclient import exceptions from oslo_utils import timeutils from oslo_utils import uuidutils -try: - import zoneinfo -except ImportError: - # zoneinfo is available in Python >= 3.9 - import pytz - zoneinfo = None - from aodh.evaluator import gnocchi from aodh import messaging from aodh.storage import models @@ -357,10 +351,7 @@ class TestGnocchiResourceThresholdEvaluate(TestGnocchiEvaluatorBase): 'duration': 10800, # 3 hours 'timezone': 'Europe/Ljubljana'} ] - if zoneinfo: - tzinfo = zoneinfo.ZoneInfo('Europe/Ljubljana') - else: - tzinfo = pytz.timezone('Europe/Ljubljana') + tzinfo = zoneinfo.ZoneInfo('Europe/Ljubljana') dt = datetime.datetime(2014, 1, 1, 15, 0, 0, tzinfo=tzinfo) mock_utcnow.return_value = dt.astimezone(datetime.timezone.utc) self.client.metric.get_measures.return_value = [] @@ -382,10 +373,7 @@ class TestGnocchiResourceThresholdEvaluate(TestGnocchiEvaluatorBase): 'duration': 10800, # 3 hours 'timezone': 'Europe/Ljubljana'} ] - if zoneinfo: - tzinfo = zoneinfo.ZoneInfo('Europe/Ljubljana') - else: - tzinfo = pytz.timezone('Europe/Ljubljana') + tzinfo = zoneinfo.ZoneInfo('Europe/Ljubljana') dt = datetime.datetime(2014, 1, 1, 12, 0, 0, tzinfo=tzinfo) mock_utcnow.return_value = dt.astimezone(datetime.timezone.utc) self.client.metric.get_measures.return_value = [] diff --git a/releasenotes/notes/drop-python-3-8-24f35246e92cf9af.yaml b/releasenotes/notes/drop-python-3-8-24f35246e92cf9af.yaml new file mode 100644 index 000000000..a0440dc80 --- /dev/null +++ b/releasenotes/notes/drop-python-3-8-24f35246e92cf9af.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - | + Python 3.8 support was dropped. The minimum version of Python now supported + is Python 3.9. diff --git a/requirements.txt b/requirements.txt index 0e5fa54e9..26cd7daa4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,7 +19,6 @@ oslo.messaging>=5.2.0 # Apache-2.0 oslo.middleware>=3.22.0 # Apache-2.0 oslo.utils>=4.7.0 # Apache-2.0 python-keystoneclient>=1.6.0 -pytz>=2013.6;python_version<"3.9" # MIT requests>=2.5.2 stevedore>=1.5.0 # Apache-2.0 SQLAlchemy>=1.4.1 @@ -34,4 +33,4 @@ python-observabilityclient>=0.0.4 python-octaviaclient>=1.8.0 python-dateutil>=2.8.2 # BSD python-heatclient>=1.17.0 -tzdata>=2022.4;python_version>="3.9" # MIT +tzdata>=2022.4 diff --git a/setup.cfg b/setup.cfg index ec8614c8f..c6dc0d9cc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,7 @@ description_file = author = OpenStack author_email = openstack-discuss@lists.openstack.org home_page = https://docs.openstack.org/aodh/latest/ -python_requires = >=3.8 +python_requires = >=3.9 classifier = Environment :: OpenStack Intended Audience :: Information Technology @@ -18,7 +18,6 @@ classifier = Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11