From 4fd43bc909adf79bed2f0ba14fef74882db11c8f Mon Sep 17 00:00:00 2001 From: Nabarun Pal Date: Thu, 27 May 2021 18:34:53 +0530 Subject: [PATCH] Apply hotfixes Signed-off-by: Nabarun Pal --- kubernetes/client/api/custom_objects_api.py | 12 +++++----- kubernetes/client/apis/__init__.py | 13 +++++++++++ kubernetes/test/test_api_client.py | 25 +++++++++++++++++++++ 3 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 kubernetes/client/apis/__init__.py create mode 100644 kubernetes/test/test_api_client.py diff --git a/kubernetes/client/api/custom_objects_api.py b/kubernetes/client/api/custom_objects_api.py index 613763b59b..2e038a914f 100644 --- a/kubernetes/client/api/custom_objects_api.py +++ b/kubernetes/client/api/custom_objects_api.py @@ -2425,7 +2425,7 @@ def patch_cluster_custom_object_with_http_info(self, group, version, plural, nam # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json-patch+json', 'application/merge-patch+json']) # noqa: E501 + ['application/merge-patch+json']) # noqa: E501 # Authentication setting auth_settings = ['BearerToken'] # noqa: E501 @@ -2594,7 +2594,7 @@ def patch_cluster_custom_object_scale_with_http_info(self, group, version, plura # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json-patch+json', 'application/merge-patch+json']) # noqa: E501 + ['application/merge-patch+json']) # noqa: E501 # Authentication setting auth_settings = ['BearerToken'] # noqa: E501 @@ -2763,7 +2763,7 @@ def patch_cluster_custom_object_status_with_http_info(self, group, version, plur # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json-patch+json', 'application/merge-patch+json']) # noqa: E501 + ['application/merge-patch+json']) # noqa: E501 # Authentication setting auth_settings = ['BearerToken'] # noqa: E501 @@ -2941,7 +2941,7 @@ def patch_namespaced_custom_object_with_http_info(self, group, version, namespac # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json-patch+json', 'application/merge-patch+json']) # noqa: E501 + ['application/merge-patch+json']) # noqa: E501 # Authentication setting auth_settings = ['BearerToken'] # noqa: E501 @@ -3119,7 +3119,7 @@ def patch_namespaced_custom_object_scale_with_http_info(self, group, version, na # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json-patch+json', 'application/merge-patch+json', 'application/apply-patch+yaml']) # noqa: E501 + ['application/merge-patch+json']) # noqa: E501 # Authentication setting auth_settings = ['BearerToken'] # noqa: E501 @@ -3297,7 +3297,7 @@ def patch_namespaced_custom_object_status_with_http_info(self, group, version, n # HTTP header `Content-Type` header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json-patch+json', 'application/merge-patch+json', 'application/apply-patch+yaml']) # noqa: E501 + ['application/merge-patch+json']) # noqa: E501 # Authentication setting auth_settings = ['BearerToken'] # noqa: E501 diff --git a/kubernetes/client/apis/__init__.py b/kubernetes/client/apis/__init__.py new file mode 100644 index 0000000000..ca4b321de2 --- /dev/null +++ b/kubernetes/client/apis/__init__.py @@ -0,0 +1,13 @@ +from __future__ import absolute_import +import warnings + +# flake8: noqa + +# alias kubernetes.client.api package and print deprecation warning +from kubernetes.client.api import * + +warnings.filterwarnings('default', module='kubernetes.client.apis') +warnings.warn( + "The package kubernetes.client.apis is renamed and deprecated, use kubernetes.client.api instead (please note that the trailing s was removed).", + DeprecationWarning +) diff --git a/kubernetes/test/test_api_client.py b/kubernetes/test/test_api_client.py new file mode 100644 index 0000000000..f0a9416cf7 --- /dev/null +++ b/kubernetes/test/test_api_client.py @@ -0,0 +1,25 @@ +# coding: utf-8 + + +import atexit +import weakref +import unittest + +import kubernetes + + +class TestApiClient(unittest.TestCase): + + def test_context_manager_closes_threadpool(self): + with kubernetes.client.ApiClient() as client: + self.assertIsNotNone(client.pool) + pool_ref = weakref.ref(client._pool) + self.assertIsNotNone(pool_ref()) + self.assertIsNone(pool_ref()) + + def test_atexit_closes_threadpool(self): + client = kubernetes.client.ApiClient() + self.assertIsNotNone(client.pool) + self.assertIsNotNone(client._pool) + atexit._run_exitfuncs() + self.assertIsNone(client._pool)