From 912cb59be58c39ee92893b98d74eef837fdf0c7f Mon Sep 17 00:00:00 2001 From: Sergii Tkachenko Date: Fri, 11 Aug 2023 16:43:07 -0400 Subject: [PATCH] [PSM Interop] Ignore DeprecationWarning: HTTPResponse.getheaders() (#34018) Disables the warning produced by kubernetes/client/rest.py calling the deprecated `urllib3.response.HTTPResponse.getheaders`, `urllib3.response.HTTPResponse.getheader` methods: ``` venv-test/lib/python3.9/site-packages/kubernetes/client/rest.py:44: DeprecationWarning: HTTPResponse.getheaders() is deprecated and will be removed in urllib3 v2.1.0. Instead access HTTPResponse.headers directly. return self.urllib3_response.getheaders() ``` This issue introduced by openapi-generator, and solved in `v6.4.0`. To fix the issue properly, kubernetes/python folks need to regenerate the library using newer openapi-generator. The most recent release `v27.2.0` still used openapi-generator [`v4.3.0`](https://github.com/kubernetes-client/python/blob/v27.2.0/kubernetes/.openapi-generator/VERSION). Since they release two times a year, and the 2 major version difference of openapi-generator, the fix may take a while. Created an issue in their repo: https://github.com/kubernetes-client/python/issues/2101. --- .../framework/infrastructure/k8s.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/run_tests/xds_k8s_test_driver/framework/infrastructure/k8s.py b/tools/run_tests/xds_k8s_test_driver/framework/infrastructure/k8s.py index 58f0ff8bb9f..afb41c4f5ff 100644 --- a/tools/run_tests/xds_k8s_test_driver/framework/infrastructure/k8s.py +++ b/tools/run_tests/xds_k8s_test_driver/framework/infrastructure/k8s.py @@ -20,6 +20,7 @@ import logging import pathlib import threading from typing import Any, Callable, List, Optional, Tuple +import warnings from kubernetes import client from kubernetes import utils @@ -105,6 +106,17 @@ class KubernetesApiManager: self.apps = client.AppsV1Api(self.client) self.core = client.CoreV1Api(self.client) self._apis = {self.apps, self.core} + # TODO(https://github.com/kubernetes-client/python/issues/2101): remove + # when the issue is solved, and the kubernetes dependency is bumped. + warnings.filterwarnings( + "ignore", + category=DeprecationWarning, + module="kubernetes", + message=( + "HTTPResponse.getheaders?\\(\\) is deprecated" + " and will be removed in urllib3 v2.1.0." + ), + ) @property def client(self) -> ApiClient: