From 099de8aaf484ee9ff7b30a7ad7766d1f023b618e Mon Sep 17 00:00:00 2001 From: "SPEARS, DUSTIN (ds443n)" Date: Fri, 6 Jan 2023 15:37:00 -0500 Subject: [PATCH] Bump k8s client to v25.3.0 Bumping k8s client to v25.3.0 Cronjob batch v1beta1 no longer available in k8s 1.25 Update tox.ini file to be compatible with v4 Change-Id: Iac79c52c97c9ef1223ae8d502da1572ef8d068fa --- armada/conf/opts.py | 4 ++-- armada/handlers/k8s.py | 10 ++++------ armada/handlers/override.py | 10 +++++----- armada/handlers/wait.py | 2 +- doc/source/conf.py | 2 +- requirements.txt | 8 ++++---- test-requirements.txt | 8 ++++---- tox.ini | 21 +++++++-------------- 8 files changed, 28 insertions(+), 37 deletions(-) diff --git a/armada/conf/opts.py b/armada/conf/opts.py index e1940089..932e2d43 100644 --- a/armada/conf/opts.py +++ b/armada/conf/opts.py @@ -28,7 +28,7 @@ package. It is assumed that: """ -import collections +import collections.abc import importlib import os import pkgutil @@ -38,7 +38,7 @@ IGNORED_MODULES = ('opts', 'constants', 'utils') def list_opts(): - opts = collections.defaultdict(list) + opts = collections.abc.defaultdict(list) module_names = _list_module_names() imported_modules = _import_modules(module_names) _append_config_options(imported_modules, opts) diff --git a/armada/handlers/k8s.py b/armada/handlers/k8s.py index 1312b1d0..f9317176 100644 --- a/armada/handlers/k8s.py +++ b/armada/handlers/k8s.py @@ -55,7 +55,6 @@ class K8s(object): self.client = client.CoreV1Api(api_client) self.batch_api = client.BatchV1Api(api_client) - self.batch_v1beta1_api = client.BatchV1beta1Api(api_client) self.custom_objects = client.CustomObjectsApi(api_client) self.api_extensions = client.ApiextensionsV1Api(api_client) self.apps_v1_api = client.AppsV1Api(api_client) @@ -96,9 +95,9 @@ class K8s(object): :param timeout: The timeout to wait for the delete to complete ''' self._delete_item_action( - self.batch_v1beta1_api.list_namespaced_cron_job, - self.batch_v1beta1_api.delete_namespaced_cron_job, "cron job", - name, namespace, propagation_policy, timeout) + self.batch_api.list_namespaced_cron_job, + self.batch_api.delete_namespaced_cron_job, "cron job", name, + namespace, propagation_policy, timeout) def delete_pod_action( self, @@ -225,8 +224,7 @@ class K8s(object): ''' try: - return self.batch_v1beta1_api.list_namespaced_cron_job( - namespace, **kwargs) + return self.batch_api.list_namespaced_cron_job(namespace, **kwargs) except ApiException as e: LOG.error( "Exception getting cron jobs: namespace=%s, label=%s: %s", diff --git a/armada/handlers/override.py b/armada/handlers/override.py index 466c817f..a7c83ebc 100644 --- a/armada/handlers/override.py +++ b/armada/handlers/override.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import collections +import collections.abc import json import yaml @@ -54,7 +54,7 @@ class Override(object): def update(self, d, u): for k, v in u.items(): - if isinstance(v, collections.Mapping): + if isinstance(v, collections.abc.Mapping): r = self.update(d.get(k, {}), v) d[k] = r elif isinstance(v, str) and isinstance(d.get(k), (list, tuple)): @@ -90,9 +90,9 @@ class Override(object): def convert(data): if isinstance(data, str): return str(data) - elif isinstance(data, collections.Mapping): + elif isinstance(data, collections.abc.Mapping): return dict(map(convert, data.items())) - elif isinstance(data, collections.Iterable): + elif isinstance(data, collections.abc.Iterable): return type(data)(map(convert, data)) else: return data @@ -113,7 +113,7 @@ class Override(object): t = t.setdefault(part, {}) string = json.dumps(tree).replace('null', '"{}"'.format(new_value)) - data_obj = convert(json.loads(string, encoding='utf-8')) + data_obj = convert(json.loads(string)) return data_obj diff --git a/armada/handlers/wait.py b/armada/handlers/wait.py index 5fcfa14f..4515cc26 100644 --- a/armada/handlers/wait.py +++ b/armada/handlers/wait.py @@ -13,7 +13,7 @@ # limitations under the License. from abc import ABC, abstractmethod -import collections +import collections.abc import copy import math import re diff --git a/doc/source/conf.py b/doc/source/conf.py index b4826c71..c8a89190 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -19,7 +19,7 @@ import os import sys sys.path.insert(0, os.path.abspath('.')) - +sys.path.insert(0, os.path.abspath('../..')) # -- General configuration ------------------------------------------------ diff --git a/requirements.txt b/requirements.txt index 6837d3fa..6246d4ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ amqp<2.7,>=2.6.0 -deepdiff==3.3.0 +deepdiff>=3.3.0 gitpython jsonschema>=3.0.1,<4 keystoneauth1>=3.18.0 -keystonemiddleware==5.3.0 +keystonemiddleware>=5.3.0 kombu<4.7,>=4.6.10 -kubernetes~=24.2.0; python_version >= '3.6' +kubernetes~=25.3.0; python_version >= '3.6' Paste>=2.0.3 PasteDeploy>=1.5.2 pylibyaml~=0.1 @@ -32,5 +32,5 @@ oslo.log>=3.45.2 # Apache-2.0 oslo.messaging!=5.25.0,>=5.24.2 # Apache-2.0 oslo.middleware>=3.27.0 # Apache-2.0 oslo.policy>=1.23.0 # Apache-2.0 -oslo.serialization==2.29.2 # Apache-2.0 +oslo.serialization>=2.29.2 # Apache-2.0 oslo.utils>=3.42.1 # Apache-2.0 diff --git a/test-requirements.txt b/test-requirements.txt index a2c50d41..cba98b8d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -15,9 +15,9 @@ flake8>=3.3.0 mock responses>=0.8.1 yapf==0.27.0 -flake8-import-order==0.18.1 +flake8-import-order>=0.18.1 -grpcio-tools==1.16.0 -typing-extensions==3.7.2 -cmd2==1.5.0 +grpcio-tools>=1.16.0 +typing-extensions>=3.7.2 +cmd2>=1.5.0 stestr diff --git a/tox.ini b/tox.ini index 29782a41..f625eb16 100644 --- a/tox.ini +++ b/tox.ini @@ -1,18 +1,18 @@ [tox] skipsdist = True minversion = 2.3.1 -envlist = py35, pep8, cover, bandit +envlist = py38, pep8, cover, bandit [testenv] deps= -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -passenv=HTTP_PROXY HTTPS_PROXY http_proxy https_proxy NO_PROXY no_proxy +passenv=HTTP_PROXY,HTTPS_PROXY,http_proxy,https_proxy,NO_PROXY,no_proxy setenv= VIRTUAL_ENV={envdir} usedevelop = True install_command = pip install {opts} {packages} -whitelist_externals = +allowlist_externals = bash find rm @@ -21,19 +21,10 @@ commands = rm -Rf .testrepository/times.dbm [testenv:venv] -basepython=python3 commands = {posargs} -[testenv:py35] -basepython = python3.5 -commands = - {[testenv]commands} - stestr run {posargs} - stestr slowest - -[testenv:py36] -basepython = python3.6 +[testenv:py38] commands = {[testenv]commands} stestr run {posargs} @@ -41,7 +32,9 @@ commands = [testenv:docs] basepython = python3 -deps = -r{toxinidir}/doc/requirements.txt +deps= + -r{toxinidir}/requirements.txt + -r{toxinidir}/doc/requirements.txt commands = rm -rf doc/build sphinx-build -W -b html doc/source doc/build/html