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
This commit is contained in:
SPEARS, DUSTIN (ds443n) 2023-01-06 15:37:00 -05:00
parent 379c88d619
commit 099de8aaf4
8 changed files with 28 additions and 37 deletions

View File

@ -28,7 +28,7 @@ package. It is assumed that:
""" """
import collections import collections.abc
import importlib import importlib
import os import os
import pkgutil import pkgutil
@ -38,7 +38,7 @@ IGNORED_MODULES = ('opts', 'constants', 'utils')
def list_opts(): def list_opts():
opts = collections.defaultdict(list) opts = collections.abc.defaultdict(list)
module_names = _list_module_names() module_names = _list_module_names()
imported_modules = _import_modules(module_names) imported_modules = _import_modules(module_names)
_append_config_options(imported_modules, opts) _append_config_options(imported_modules, opts)

View File

@ -55,7 +55,6 @@ class K8s(object):
self.client = client.CoreV1Api(api_client) self.client = client.CoreV1Api(api_client)
self.batch_api = client.BatchV1Api(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.custom_objects = client.CustomObjectsApi(api_client)
self.api_extensions = client.ApiextensionsV1Api(api_client) self.api_extensions = client.ApiextensionsV1Api(api_client)
self.apps_v1_api = client.AppsV1Api(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 :param timeout: The timeout to wait for the delete to complete
''' '''
self._delete_item_action( self._delete_item_action(
self.batch_v1beta1_api.list_namespaced_cron_job, self.batch_api.list_namespaced_cron_job,
self.batch_v1beta1_api.delete_namespaced_cron_job, "cron job", self.batch_api.delete_namespaced_cron_job, "cron job", name,
name, namespace, propagation_policy, timeout) namespace, propagation_policy, timeout)
def delete_pod_action( def delete_pod_action(
self, self,
@ -225,8 +224,7 @@ class K8s(object):
''' '''
try: try:
return self.batch_v1beta1_api.list_namespaced_cron_job( return self.batch_api.list_namespaced_cron_job(namespace, **kwargs)
namespace, **kwargs)
except ApiException as e: except ApiException as e:
LOG.error( LOG.error(
"Exception getting cron jobs: namespace=%s, label=%s: %s", "Exception getting cron jobs: namespace=%s, label=%s: %s",

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import collections import collections.abc
import json import json
import yaml import yaml
@ -54,7 +54,7 @@ class Override(object):
def update(self, d, u): def update(self, d, u):
for k, v in u.items(): for k, v in u.items():
if isinstance(v, collections.Mapping): if isinstance(v, collections.abc.Mapping):
r = self.update(d.get(k, {}), v) r = self.update(d.get(k, {}), v)
d[k] = r d[k] = r
elif isinstance(v, str) and isinstance(d.get(k), (list, tuple)): elif isinstance(v, str) and isinstance(d.get(k), (list, tuple)):
@ -90,9 +90,9 @@ class Override(object):
def convert(data): def convert(data):
if isinstance(data, str): if isinstance(data, str):
return str(data) return str(data)
elif isinstance(data, collections.Mapping): elif isinstance(data, collections.abc.Mapping):
return dict(map(convert, data.items())) return dict(map(convert, data.items()))
elif isinstance(data, collections.Iterable): elif isinstance(data, collections.abc.Iterable):
return type(data)(map(convert, data)) return type(data)(map(convert, data))
else: else:
return data return data
@ -113,7 +113,7 @@ class Override(object):
t = t.setdefault(part, {}) t = t.setdefault(part, {})
string = json.dumps(tree).replace('null', '"{}"'.format(new_value)) 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 return data_obj

View File

@ -13,7 +13,7 @@
# limitations under the License. # limitations under the License.
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
import collections import collections.abc
import copy import copy
import math import math
import re import re

View File

@ -19,7 +19,7 @@
import os import os
import sys import sys
sys.path.insert(0, os.path.abspath('.')) sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../..'))
# -- General configuration ------------------------------------------------ # -- General configuration ------------------------------------------------

View File

@ -1,11 +1,11 @@
amqp<2.7,>=2.6.0 amqp<2.7,>=2.6.0
deepdiff==3.3.0 deepdiff>=3.3.0
gitpython gitpython
jsonschema>=3.0.1,<4 jsonschema>=3.0.1,<4
keystoneauth1>=3.18.0 keystoneauth1>=3.18.0
keystonemiddleware==5.3.0 keystonemiddleware>=5.3.0
kombu<4.7,>=4.6.10 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 Paste>=2.0.3
PasteDeploy>=1.5.2 PasteDeploy>=1.5.2
pylibyaml~=0.1 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.messaging!=5.25.0,>=5.24.2 # Apache-2.0
oslo.middleware>=3.27.0 # Apache-2.0 oslo.middleware>=3.27.0 # Apache-2.0
oslo.policy>=1.23.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 oslo.utils>=3.42.1 # Apache-2.0

View File

@ -15,9 +15,9 @@ flake8>=3.3.0
mock mock
responses>=0.8.1 responses>=0.8.1
yapf==0.27.0 yapf==0.27.0
flake8-import-order==0.18.1 flake8-import-order>=0.18.1
grpcio-tools==1.16.0 grpcio-tools>=1.16.0
typing-extensions==3.7.2 typing-extensions>=3.7.2
cmd2==1.5.0 cmd2>=1.5.0
stestr stestr

21
tox.ini
View File

@ -1,18 +1,18 @@
[tox] [tox]
skipsdist = True skipsdist = True
minversion = 2.3.1 minversion = 2.3.1
envlist = py35, pep8, cover, bandit envlist = py38, pep8, cover, bandit
[testenv] [testenv]
deps= deps=
-r{toxinidir}/requirements.txt -r{toxinidir}/requirements.txt
-r{toxinidir}/test-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= setenv=
VIRTUAL_ENV={envdir} VIRTUAL_ENV={envdir}
usedevelop = True usedevelop = True
install_command = pip install {opts} {packages} install_command = pip install {opts} {packages}
whitelist_externals = allowlist_externals =
bash bash
find find
rm rm
@ -21,19 +21,10 @@ commands =
rm -Rf .testrepository/times.dbm rm -Rf .testrepository/times.dbm
[testenv:venv] [testenv:venv]
basepython=python3
commands = commands =
{posargs} {posargs}
[testenv:py35] [testenv:py38]
basepython = python3.5
commands =
{[testenv]commands}
stestr run {posargs}
stestr slowest
[testenv:py36]
basepython = python3.6
commands = commands =
{[testenv]commands} {[testenv]commands}
stestr run {posargs} stestr run {posargs}
@ -41,7 +32,9 @@ commands =
[testenv:docs] [testenv:docs]
basepython = python3 basepython = python3
deps = -r{toxinidir}/doc/requirements.txt deps=
-r{toxinidir}/requirements.txt
-r{toxinidir}/doc/requirements.txt
commands = commands =
rm -rf doc/build rm -rf doc/build
sphinx-build -W -b html doc/source doc/build/html sphinx-build -W -b html doc/source doc/build/html