From ceae02f09d1c4e67013485c7323c11f8655c9c1e Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Thu, 24 Oct 2019 13:47:48 +0200 Subject: [PATCH] Get rid of Python 2 support 2020 came, everyone should be using Python 3 now. As per the official python support timeline set forth by the OpenStack TC [1], OpenStack Train (in our case, kolla 9.x) is the last release that will support python2.7. [1] https://governance.openstack.org/tc/resolutions/20180529-python2-deprecation-timeline.html Related bug: https://bugs.launchpad.net/tripleo/+bug/1856678 Merging depends on TripleO team - once they move CI job to CentOS 8 we can merge. Implements: blueprint drop-py2-support Change-Id: Ic459561ab6ab8c62993c044c7a82d887839da289 --- doc/requirements.txt | 1 - kolla/common/task.py | 5 +-- kolla/image/build.py | 36 +++++++++---------- .../notes/drop-py27-a16f4712ac89e3a9.yaml | 6 ++++ requirements.txt | 4 +-- setup.cfg | 2 -- tox.ini | 3 -- 7 files changed, 25 insertions(+), 32 deletions(-) create mode 100644 releasenotes/notes/drop-py27-a16f4712ac89e3a9.yaml diff --git a/doc/requirements.txt b/doc/requirements.txt index c36e117d78..a09abef7bb 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -5,6 +5,5 @@ doc8>=0.6.0 # Apache-2.0 openstackdocstheme>=1.19.0 # Apache-2.0 reno>=2.5.0 # Apache-2.0 -sphinx>=1.8.0,<2.0.0;python_version=='2.7' # BSD sphinx>=1.8.0,!=2.1.0;python_version>='3.4' # BSD sphinxcontrib-svg2pdfconverter>=0.1.0 # BSD diff --git a/kolla/common/task.py b/kolla/common/task.py index ff23e2ad88..5632423d5b 100644 --- a/kolla/common/task.py +++ b/kolla/common/task.py @@ -12,11 +12,8 @@ import abc -import six - -@six.add_metaclass(abc.ABCMeta) -class Task(object): +class Task(object, metaclass=abc.ABCMeta): def __init__(self): self.success = False diff --git a/kolla/image/build.py b/kolla/image/build.py index e7936590e1..f07cb777f5 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -12,14 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -from __future__ import print_function - import contextlib import datetime import errno import json import logging import os +import queue import re import requests import shutil @@ -36,7 +35,6 @@ import git import jinja2 from oslo_config import cfg from requests import exceptions as requests_exc -import six # NOTE(SamYaple): Update the search path to prefer PROJECT_ROOT as the source @@ -683,7 +681,7 @@ class WorkerThread(threading.Thread): self.queue.put(task) break try: - for attempt in six.moves.range(self.conf.retries + 1): + for attempt in range(self.conf.retries + 1): if self.should_stop: break LOG.info("Attempt number: %s to run task: %s ", @@ -944,7 +942,7 @@ class KollaWorker(object): } def get_users(self): - all_sections = (set(six.iterkeys(self.conf._groups)) | + all_sections = (set(self.conf._groups.keys()) | set(self.conf.list_all_sections())) ret = dict() for section in all_sections: @@ -1274,7 +1272,7 @@ class KollaWorker(object): installation['reference'] = self.conf[section]['reference'] return installation - all_sections = (set(six.iterkeys(self.conf._groups)) | + all_sections = (set(self.conf._groups.keys()) | set(self.conf.list_all_sections())) for path in self.docker_build_paths: @@ -1371,7 +1369,7 @@ class KollaWorker(object): return def list_children(images, ancestry): - children = six.next(iter(ancestry.values())) + children = next(iter(ancestry.values())) for image in images: if image.status not in [STATUS_MATCHED]: continue @@ -1405,7 +1403,7 @@ class KollaWorker(object): Return a list of Queues that have been organized into a hierarchy based on dependencies """ - queue = six.moves.queue.Queue() + build_queue = queue.Queue() for image in self.images: if image.status in (STATUS_UNMATCHED, STATUS_SKIPPED, @@ -1417,10 +1415,10 @@ class KollaWorker(object): # Build all root nodes, where a root is defined as having no parent # or having a parent that is explicitly being skipped. if image.parent is None or image.parent.status == STATUS_SKIPPED: - queue.put(BuildTask(self.conf, image, push_queue)) + build_queue.put(BuildTask(self.conf, image, push_queue)) LOG.info('Added image %s to queue', image.name) - return queue + return build_queue def run_build(): @@ -1474,36 +1472,36 @@ def run_build(): kolla.list_dependencies() return - push_queue = six.moves.queue.Queue() - queue = kolla.build_queue(push_queue) + push_queue = queue.Queue() + build_queue = kolla.build_queue(push_queue) workers = [] with join_many(workers): try: - for x in six.moves.range(conf.threads): - worker = WorkerThread(conf, queue) + for x in range(conf.threads): + worker = WorkerThread(conf, build_queue) worker.setDaemon(True) worker.start() workers.append(worker) - for x in six.moves.range(conf.push_threads): + for x in range(conf.push_threads): worker = WorkerThread(conf, push_queue) worker.setDaemon(True) worker.start() workers.append(worker) - # sleep until queue is empty - while queue.unfinished_tasks or push_queue.unfinished_tasks: + # sleep until build_queue is empty + while build_queue.unfinished_tasks or push_queue.unfinished_tasks: time.sleep(3) # ensure all threads exited happily push_queue.put(WorkerThread.tombstone) - queue.put(WorkerThread.tombstone) + build_queue.put(WorkerThread.tombstone) except KeyboardInterrupt: for w in workers: w.should_stop = True push_queue.put(WorkerThread.tombstone) - queue.put(WorkerThread.tombstone) + build_queue.put(WorkerThread.tombstone) raise results = kolla.summary() diff --git a/releasenotes/notes/drop-py27-a16f4712ac89e3a9.yaml b/releasenotes/notes/drop-py27-a16f4712ac89e3a9.yaml new file mode 100644 index 0000000000..ea09134c46 --- /dev/null +++ b/releasenotes/notes/drop-py27-a16f4712ac89e3a9.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - | + Python 2.7 support has been dropped. Last release of kolla to support + Python 2.7 is OpenStack Train. The minimum version of Python now supported + by kolla is Python 3.6. diff --git a/requirements.txt b/requirements.txt index d030b92801..d4ef17487a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,9 +4,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 docker>=2.4.2 # Apache-2.0 Jinja2>=2.8 # BSD License (3 clause) -GitPython>=1.0.1,<2.1.12;python_version<'3.0' # BSD License (3 clause) -GitPython>=1.0.1;python_version>='3.0' # BSD License (3 clause) -six>=1.10.0 # MIT +GitPython>=1.0.1;python_version>='3.0' # BSD License (3 clause) oslo.config>=5.1.0 # Apache-2.0 oslo.utils>=3.33.0 # Apache-2.0 setuptools!=24.0.0,!=34.0.0,!=34.0.1,!=34.0.2,!=34.0.3,!=34.1.0,!=34.1.1,!=34.2.0,!=34.3.0,!=34.3.1,!=34.3.2,!=36.2.0,>=21.0 # PSF/ZPL diff --git a/setup.cfg b/setup.cfg index 535aff89fe..1116c2e621 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,8 +14,6 @@ classifier = License :: OSI Approved :: Apache Software License Operating System :: POSIX :: Linux Programming Language :: Python - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 diff --git a/tox.ini b/tox.ini index 06679d5197..4dba8b5475 100644 --- a/tox.ini +++ b/tox.ini @@ -21,9 +21,6 @@ commands = stestr run {posargs} stestr slowest -[testenv:py27] -basepython = python2.7 - [testenv:py36] basepython = python3.6