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
This commit is contained in:
Marcin Juszkiewicz 2019-10-24 13:47:48 +02:00 committed by Radosław Piliszek
parent 1b0884af8a
commit ceae02f09d
7 changed files with 25 additions and 32 deletions

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -21,9 +21,6 @@ commands =
stestr run {posargs}
stestr slowest
[testenv:py27]
basepython = python2.7
[testenv:py36]
basepython = python3.6