Browse Source

Removing six library.

Since we already migrated fully to Python3, it's time to also remove
bits needed for Python2. One of those libs is six.

Change-Id: Ib984d7b4b3c1048ed091c78986c634689a8ace8c
changes/33/710433/2
Roman Dobosz 1 year ago
parent
commit
ded6b6debc
27 changed files with 64 additions and 109 deletions
  1. +1
    -1
      contrib/pools-management/subports.py
  2. +3
    -6
      kuryr_kubernetes/cni/api.py
  3. +1
    -3
      kuryr_kubernetes/cni/binding/base.py
  4. +2
    -3
      kuryr_kubernetes/cni/binding/nested.py
  5. +1
    -1
      kuryr_kubernetes/cni/daemon/service.py
  6. +1
    -3
      kuryr_kubernetes/cni/handlers.py
  7. +1
    -1
      kuryr_kubernetes/cni/health.py
  8. +1
    -5
      kuryr_kubernetes/cni/main.py
  9. +1
    -3
      kuryr_kubernetes/cni/plugins/base.py
  10. +14
    -29
      kuryr_kubernetes/controller/drivers/base.py
  11. +2
    -3
      kuryr_kubernetes/controller/drivers/nested_vif.py
  12. +1
    -3
      kuryr_kubernetes/controller/drivers/public_ip.py
  13. +7
    -6
      kuryr_kubernetes/controller/drivers/utils.py
  14. +1
    -3
      kuryr_kubernetes/controller/drivers/vif_pool.py
  15. +1
    -1
      kuryr_kubernetes/controller/managers/health.py
  16. +4
    -4
      kuryr_kubernetes/controller/managers/pool.py
  17. +2
    -4
      kuryr_kubernetes/controller/service.py
  18. +3
    -3
      kuryr_kubernetes/handlers/asynchronous.py
  19. +1
    -3
      kuryr_kubernetes/handlers/base.py
  20. +2
    -5
      kuryr_kubernetes/handlers/dispatch.py
  21. +2
    -3
      kuryr_kubernetes/objects/base.py
  22. +3
    -3
      kuryr_kubernetes/tests/unit/cmd/test_status.py
  23. +3
    -4
      kuryr_kubernetes/tests/unit/cni/test_api.py
  24. +2
    -3
      kuryr_kubernetes/tests/unit/controller/drivers/test_base.py
  25. +4
    -4
      kuryr_kubernetes/tests/unit/handlers/test_asynchronous.py
  26. +0
    -1
      lower-constraints.txt
  27. +0
    -1
      requirements.txt

+ 1
- 1
contrib/pools-management/subports.py View File

@ -13,10 +13,10 @@
# limitations under the License.
import argparse
from http import client as httplib
import socket
from oslo_serialization import jsonutils
from six.moves import http_client as httplib
from kuryr_kubernetes import constants


+ 3
- 6
kuryr_kubernetes/cni/api.py View File

@ -15,16 +15,14 @@
import abc
import six
from six.moves import http_client as httplib
from http import client as httplib
import traceback
import requests
from kuryr.lib._i18n import _
from os_vif.objects import base
from oslo_log import log as logging
from oslo_serialization import jsonutils
import requests
from kuryr_kubernetes import config
from kuryr_kubernetes import constants as k_const
@ -33,8 +31,7 @@ from kuryr_kubernetes import exceptions as k_exc
LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class CNIRunner(object):
class CNIRunner(object, metaclass=abc.ABCMeta):
# TODO(ivc): extend SUPPORTED_VERSIONS and format output based on
# requested params.CNI_VERSION and/or params.config.cniVersion
VERSION = '0.3.1'


+ 1
- 3
kuryr_kubernetes/cni/binding/base.py View File

@ -15,7 +15,6 @@
import abc
import errno
import six
import os_vif
from oslo_log import log as logging
@ -30,8 +29,7 @@ _BINDING_NAMESPACE = 'kuryr_kubernetes.cni.binding'
LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class BaseBindingDriver(object):
class BaseBindingDriver(object, metaclass=abc.ABCMeta):
"""Interface to attach ports to pods."""
def _remove_ifaces(self, ipdb, ifnames, netns='host'):


+ 2
- 3
kuryr_kubernetes/cni/binding/nested.py View File

@ -14,7 +14,6 @@
import abc
import errno
import six
from oslo_log import log as logging
import pyroute2
@ -32,8 +31,8 @@ MACVLAN_MODE_BRIDGE = 'bridge'
LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class NestedDriver(health.HealthHandler, b_base.BaseBindingDriver):
class NestedDriver(health.HealthHandler, b_base.BaseBindingDriver,
metaclass=abc.ABCMeta):
def __init__(self):
super(NestedDriver, self).__init__()


+ 1
- 1
kuryr_kubernetes/cni/daemon/service.py View File

@ -13,9 +13,9 @@
# limitations under the License.
from ctypes import c_bool
from http import client as httplib
import multiprocessing
import os
from six.moves import http_client as httplib
import socket
import sys
import threading


+ 1
- 3
kuryr_kubernetes/cni/handlers.py View File

@ -14,7 +14,6 @@
# under the License.
import abc
import six
from os_vif import objects as obj_vif
from oslo_log import log as logging
@ -28,8 +27,7 @@ from kuryr_kubernetes import utils
LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class CNIHandlerBase(k8s_base.ResourceEventHandler):
class CNIHandlerBase(k8s_base.ResourceEventHandler, metaclass=abc.ABCMeta):
OBJECT_KIND = k_const.K8S_OBJ_POD
def __init__(self, cni, on_done):


+ 1
- 1
kuryr_kubernetes/cni/health.py View File

@ -10,8 +10,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from http import client as httplib
import os
from six.moves import http_client as httplib
from flask import Flask
from pyroute2 import IPDB


+ 1
- 5
kuryr_kubernetes/cni/main.py View File

@ -15,7 +15,6 @@
import os
import signal
import six
import sys
import os_vif
@ -35,10 +34,7 @@ _CNI_TIMEOUT = 180
def run():
if six.PY3:
d = jsonutils.load(sys.stdin.buffer)
else:
d = jsonutils.load(sys.stdin)
d = jsonutils.load(sys.stdin.buffer)
cni_conf = utils.CNIConfig(d)
args = (['--config-file', cni_conf.kuryr_conf] if 'kuryr_conf' in d
else [])


+ 1
- 3
kuryr_kubernetes/cni/plugins/base.py View File

@ -15,11 +15,9 @@
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class CNIPlugin(object):
class CNIPlugin(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def add(self, params):


+ 14
- 29
kuryr_kubernetes/controller/drivers/base.py View File

@ -14,7 +14,6 @@
# under the License.
import abc
import six
from kuryr.lib._i18n import _
from stevedore import driver as stv_driver
@ -38,8 +37,7 @@ class DriverBase(object):
Usage example:
@six.add_metaclass(abc.ABCMeta)
class SomeDriverInterface(DriverBase):
class SomeDriverInterface(DriverBase, metaclass=abc.ABCMeta):
ALIAS = 'driver_alias'
@abc.abstractmethod
@ -93,8 +91,7 @@ class DriverBase(object):
return self.__class__.__name__
@six.add_metaclass(abc.ABCMeta)
class PodProjectDriver(DriverBase):
class PodProjectDriver(DriverBase, metaclass=abc.ABCMeta):
"""Provides an OpenStack project ID for Kubernetes Pod ports."""
ALIAS = 'pod_project'
@ -110,8 +107,7 @@ class PodProjectDriver(DriverBase):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class ServiceProjectDriver(DriverBase):
class ServiceProjectDriver(DriverBase, metaclass=abc.ABCMeta):
"""Provides an OpenStack project ID for Kubernetes Services."""
ALIAS = 'service_project'
@ -127,8 +123,7 @@ class ServiceProjectDriver(DriverBase):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class NamespaceProjectDriver(DriverBase):
class NamespaceProjectDriver(DriverBase, metaclass=abc.ABCMeta):
"""Provides an OpenStack project ID for Kubernetes Namespace."""
ALIAS = 'namespace_project'
@ -144,8 +139,7 @@ class NamespaceProjectDriver(DriverBase):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class PodSubnetsDriver(DriverBase):
class PodSubnetsDriver(DriverBase, metaclass=abc.ABCMeta):
"""Provides subnets for Kubernetes Pods."""
ALIAS = 'pod_subnets'
@ -202,8 +196,7 @@ class PodSubnetsDriver(DriverBase):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class ServiceSubnetsDriver(DriverBase):
class ServiceSubnetsDriver(DriverBase, metaclass=abc.ABCMeta):
"""Provides subnets for Kubernetes Services."""
ALIAS = 'service_subnets'
@ -222,8 +215,7 @@ class ServiceSubnetsDriver(DriverBase):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class PodSecurityGroupsDriver(DriverBase):
class PodSecurityGroupsDriver(DriverBase, metaclass=abc.ABCMeta):
"""Provides security groups for Kubernetes Pods."""
ALIAS = 'pod_security_groups'
@ -287,8 +279,7 @@ class PodSecurityGroupsDriver(DriverBase):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class ServiceSecurityGroupsDriver(DriverBase):
class ServiceSecurityGroupsDriver(DriverBase, metaclass=abc.ABCMeta):
"""Provides security groups for Kubernetes Services."""
ALIAS = 'service_security_groups'
@ -304,8 +295,7 @@ class ServiceSecurityGroupsDriver(DriverBase):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class PodVIFDriver(DriverBase):
class PodVIFDriver(DriverBase, metaclass=abc.ABCMeta):
"""Manages Neutron ports to provide VIFs for Kubernetes Pods."""
ALIAS = 'pod_vif'
@ -433,8 +423,7 @@ class PodVIFDriver(DriverBase):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class MultiVIFDriver(DriverBase):
class MultiVIFDriver(DriverBase, metaclass=abc.ABCMeta):
"""Manages additional ports of Kubernetes Pods."""
ALIAS = 'multi_vif'
@ -626,8 +615,7 @@ class LBaaSDriver(DriverBase):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class VIFPoolDriver(PodVIFDriver):
class VIFPoolDriver(PodVIFDriver, metaclass=abc.ABCMeta):
"""Manages Pool of Neutron ports to provide VIFs for Kubernetes Pods."""
ALIAS = 'vif_pool'
@ -657,8 +645,7 @@ class VIFPoolDriver(PodVIFDriver):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class ServicePubIpDriver(DriverBase):
class ServicePubIpDriver(DriverBase, metaclass=abc.ABCMeta):
"""Manages loadbalancerIP/public ip for neutron lbaas."""
ALIAS = 'service_public_ip'
@ -705,8 +692,7 @@ class ServicePubIpDriver(DriverBase):
"""
@six.add_metaclass(abc.ABCMeta)
class NetworkPolicyDriver(DriverBase):
class NetworkPolicyDriver(DriverBase, metaclass=abc.ABCMeta):
"""Provide network-policy for pods"""
ALIAS = 'network_policy'
@ -777,8 +763,7 @@ class NetworkPolicyDriver(DriverBase):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class NetworkPolicyProjectDriver(DriverBase):
class NetworkPolicyProjectDriver(DriverBase, metaclass=abc.ABCMeta):
"""Get an OpenStack project id for K8s network policies"""
ALIAS = 'network_policy_project'


+ 2
- 3
kuryr_kubernetes/controller/drivers/nested_vif.py View File

@ -13,7 +13,6 @@
# under the License.
import abc
import six
from kuryr.lib import exceptions as kl_exc
from openstack import exceptions as os_exc
@ -27,8 +26,8 @@ from kuryr_kubernetes.controller.drivers import neutron_vif
LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class NestedPodVIFDriver(neutron_vif.NeutronPodVIFDriver):
class NestedPodVIFDriver(neutron_vif.NeutronPodVIFDriver,
metaclass=abc.ABCMeta):
"""Skeletal handler driver for VIFs for Nested Pods."""
def _get_parent_port_by_host_ip(self, node_fixed_ip):


+ 1
- 3
kuryr_kubernetes/controller/drivers/public_ip.py View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import abc
import six
from openstack import exceptions as os_exc
from oslo_log import log as logging
@ -24,8 +23,7 @@ from kuryr_kubernetes.controller.drivers import utils
LOG = logging.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta)
class BasePubIpDriver(object):
class BasePubIpDriver(object, metaclass=abc.ABCMeta):
"""Base class for public IP functionality."""
@abc.abstractmethod


+ 7
- 6
kuryr_kubernetes/controller/drivers/utils.py View File

@ -13,12 +13,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import urllib
from openstack import exceptions as os_exc
from oslo_cache import core as cache
from oslo_config import cfg
from oslo_log import log
from oslo_serialization import jsonutils
from six.moves.urllib import parse
from kuryr_kubernetes import clients
from kuryr_kubernetes import constants
@ -117,10 +118,10 @@ def get_pods(selector, namespace=None):
if exps:
exps = ', '.join(format_expression(exp) for exp in exps)
if labels:
expressions = parse.quote("," + exps)
expressions = urllib.parse.quote("," + exps)
labels += expressions
else:
labels = parse.quote(exps)
labels = urllib.parse.quote(exps)
if namespace:
pods = kubernetes.get(
@ -149,10 +150,10 @@ def get_namespaces(selector):
if exps:
exps = ', '.join(format_expression(exp) for exp in exps)
if labels:
expressions = parse.quote("," + exps)
expressions = urllib.parse.quote("," + exps)
labels += expressions
else:
labels = parse.quote(exps)
labels = urllib.parse.quote(exps)
namespaces = kubernetes.get(
'{}/namespaces?labelSelector={}'.format(
@ -177,7 +178,7 @@ def format_expression(expression):
def replace_encoded_characters(labels):
labels = parse.urlencode(labels)
labels = urllib.parse.urlencode(labels)
# NOTE(ltomasbo): K8s API does not accept &, so we need to AND
# the matchLabels with ',' or '%2C' instead
labels = labels.replace('&', ',')


+ 1
- 3
kuryr_kubernetes/controller/drivers/vif_pool.py View File

@ -17,7 +17,6 @@ import abc
import collections
import eventlet
import os
import six
import time
from kuryr.lib._i18n import _
@ -130,8 +129,7 @@ class NoopVIFPool(base.VIFPoolDriver):
pass
@six.add_metaclass(abc.ABCMeta)
class BaseVIFPool(base.VIFPoolDriver):
class BaseVIFPool(base.VIFPoolDriver, metaclass=abc.ABCMeta):
"""Skeletal pool driver.
In order to handle the pools of ports, a few dicts are used:


+ 1
- 1
kuryr_kubernetes/controller/managers/health.py View File

@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from http import client as httplib
import os
from six.moves import http_client as httplib
from flask import Flask
from oslo_config import cfg


+ 4
- 4
kuryr_kubernetes/controller/managers/pool.py View File

@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from http import server
import os
import socketserver
import threading
from six.moves.BaseHTTPServer import BaseHTTPRequestHandler
from six.moves.socketserver import ThreadingUnixStreamServer
from openstack import exceptions as os_exc
from oslo_config import cfg as oslo_cfg
@ -41,11 +41,11 @@ pool_manager_opts = [
oslo_cfg.CONF.register_opts(pool_manager_opts, "pool_manager")
class UnixDomainHttpServer(ThreadingUnixStreamServer):
class UnixDomainHttpServer(socketserver.ThreadingUnixStreamServer):
pass
class RequestHandler(BaseHTTPRequestHandler):
class RequestHandler(server.BaseHTTPRequestHandler):
protocol = "HTTP/1.0"
def do_POST(self):


+ 2
- 4
kuryr_kubernetes/controller/service.py View File

@ -14,7 +14,6 @@
# under the License.
import functools
import six
import sys
import os_vif
@ -72,9 +71,8 @@ class KuryrK8sServiceMeta(type(service.Service),
pass
class KuryrK8sService(six.with_metaclass(KuryrK8sServiceMeta,
service.Service,
periodic_task.PeriodicTasks)):
class KuryrK8sService(service.Service, periodic_task.PeriodicTasks,
metaclass=KuryrK8sServiceMeta):
"""Kuryr-Kubernetes controller Service."""
def __init__(self):


+ 3
- 3
kuryr_kubernetes/handlers/asynchronous.py View File

@ -14,7 +14,7 @@
# under the License.
import itertools
from six.moves import queue as six_queue
import queue as py_queue
import time
from oslo_log import log as logging
@ -54,7 +54,7 @@ class Async(base.EventHandler):
try:
queue = self._queues[group]
except KeyError:
queue = six_queue.Queue(self._queue_depth)
queue = py_queue.Queue(self._queue_depth)
self._queues[group] = queue
thread = self._thread_group.add_thread(self._run, group, queue)
thread.link(self._done, group)
@ -68,7 +68,7 @@ class Async(base.EventHandler):
# avoid tests getting stuck in infinite loops)
try:
event = queue.get(timeout=self._grace_period)
except six_queue.Empty:
except py_queue.Empty:
break
# FIXME(ivc): temporary workaround to skip stale events
# If K8s updates resource while the handler is processing it,


+ 1
- 3
kuryr_kubernetes/handlers/base.py View File

@ -14,11 +14,9 @@
# under the License.
import abc
import six
@six.add_metaclass(abc.ABCMeta)
class EventHandler(object):
class EventHandler(object, metaclass=abc.ABCMeta):
"""Base class for event handlers."""
@abc.abstractmethod


+ 2
- 5
kuryr_kubernetes/handlers/dispatch.py View File

@ -14,7 +14,6 @@
# under the License.
import abc
import six
from oslo_log import log as logging
@ -71,8 +70,7 @@ class Dispatcher(h_base.EventHandler):
handler(event)
@six.add_metaclass(abc.ABCMeta)
class EventConsumer(h_base.EventHandler):
class EventConsumer(h_base.EventHandler, metaclass=abc.ABCMeta):
"""Consumes events matching specified predicates.
EventConsumer is an interface for all event handlers that are to be
@ -92,8 +90,7 @@ class EventConsumer(h_base.EventHandler):
raise NotImplementedError()
@six.add_metaclass(abc.ABCMeta)
class EventPipeline(h_base.EventHandler):
class EventPipeline(h_base.EventHandler, metaclass=abc.ABCMeta):
"""Serves as an entry-point for event handling.
Implementing subclasses should override `_wrap_dispatcher` and/or


+ 2
- 3
kuryr_kubernetes/objects/base.py View File

@ -14,14 +14,13 @@
# under the License.
import abc
import six
from oslo_versionedobjects import base as obj_base
@six.add_metaclass(abc.ABCMeta)
class KuryrK8sObjectBase(obj_base.VersionedObject,
obj_base.ComparableVersionedObject):
obj_base.ComparableVersionedObject,
metaclass=abc.ABCMeta):
OBJ_PROJECT_NAMESPACE = 'kuryr_kubernetes'


+ 3
- 3
kuryr_kubernetes/tests/unit/cmd/test_status.py View File

@ -12,10 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import io
import mock
from oslo_serialization import jsonutils
import six
from kuryr_kubernetes.cmd import status
from kuryr_kubernetes import constants
@ -62,7 +62,7 @@ class TestStatusCmd(test_base.TestCase):
obj = self.cmd._get_annotation(pod)
self.assertEqual(mock_obj, obj)
@mock.patch('sys.stdout', new_callable=six.StringIO)
@mock.patch('sys.stdout', new_callable=io.StringIO)
def _test_upgrade_check(self, code, code_name, m_stdout):
method_success_m = mock.Mock()
method_success_m.return_value = status.UpgradeCheckResult(0, 'foo')


+ 3
- 4
kuryr_kubernetes/tests/unit/cni/test_api.py View File

@ -13,13 +13,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from six import StringIO
import requests
from io import StringIO
import mock
from oslo_config import cfg
from oslo_serialization import jsonutils
import requests
from kuryr_kubernetes.cni import api
from kuryr_kubernetes.tests import base as test_base


+ 2
- 3
kuryr_kubernetes/tests/unit/controller/drivers/test_base.py View File

@ -14,15 +14,14 @@
# under the License.
import abc
import mock
import six
from kuryr_kubernetes.controller.drivers import base as d_base
from kuryr_kubernetes.tests import base as test_base
@six.add_metaclass(abc.ABCMeta)
class _TestDriver(d_base.DriverBase):
class _TestDriver(d_base.DriverBase, metaclass=abc.ABCMeta):
ALIAS = 'test_alias'
@abc.abstractmethod


+ 4
- 4
kuryr_kubernetes/tests/unit/handlers/test_asynchronous.py View File

@ -14,7 +14,7 @@
# under the License.
import mock
from six.moves import queue as six_queue
import queue
from kuryr_kubernetes.handlers import asynchronous as h_async
from kuryr_kubernetes.tests import base as test_base
@ -37,7 +37,7 @@ class TestAsyncHandler(test_base.TestCase):
self.assertEqual({group: m_queue}, async_handler._queues)
m_queue.put.assert_called_once_with(event)
@mock.patch('six.moves.queue.Queue')
@mock.patch('queue.Queue')
def test_call_new(self, m_queue_type):
event = mock.sentinel.event
group = mock.sentinel.group
@ -85,7 +85,7 @@ class TestAsyncHandler(test_base.TestCase):
group = mock.sentinel.group
m_queue = mock.Mock()
m_queue.empty.return_value = True
m_queue.get.side_effect = events + [six_queue.Empty()]
m_queue.get.side_effect = events + [queue.Empty()]
m_handler = mock.Mock()
m_count.return_value = list(range(5))
async_handler = h_async.Async(m_handler, mock.Mock(), mock.Mock())
@ -102,7 +102,7 @@ class TestAsyncHandler(test_base.TestCase):
group = mock.sentinel.group
m_queue = mock.Mock()
m_queue.empty.side_effect = [False, True, True]
m_queue.get.side_effect = events + [six_queue.Empty()]
m_queue.get.side_effect = events + [queue.Empty()]
m_handler = mock.Mock()
m_count.return_value = list(range(5))
async_handler = h_async.Async(m_handler, mock.Mock(), mock.Mock())


+ 0
- 1
lower-constraints.txt View File

@ -113,7 +113,6 @@ rfc3986==1.1.0
Routes==2.4.1
setproctitle==1.1.10
simplejson==3.13.2
six==1.10.0
snowballstemmer==1.2.1
Sphinx==1.6.2
sphinxcontrib-websupport==1.0.1


+ 0
- 1
requirements.txt View File

@ -21,7 +21,6 @@ os-vif>=1.12.0 # Apache-2.0
PrettyTable<0.8,>=0.7.2 # BSD
pyroute2>=0.5.7;sys_platform!='win32' # Apache-2.0 (+ dual licensed GPL2)
retrying!=1.3.0,>=1.2.3 # Apache-2.0
six>=1.10.0 # MIT
stevedore>=1.20.0 # Apache-2.0
grpcio>=1.12.0 # Apache-2.0
protobuf>=3.6.0 # 3-Clause BSD

Loading…
Cancel
Save