From 8b8ad6e6fa894b4d7c1efc2eb9cd18cef4e3f019 Mon Sep 17 00:00:00 2001 From: Luis Perez Date: Wed, 18 Oct 2023 11:23:52 -0700 Subject: [PATCH] Revert "CLUSTERMAN-812: upgrade k8s client library (#334)" This reverts commit 6c4b8bb424fd84f1087552fb19d992180cf17834. --- clusterman/kubernetes/kubernetes_cluster_connector.py | 4 ++-- clusterman/kubernetes/util.py | 3 +-- requirements.txt | 2 +- tests/kubernetes/util_test.py | 3 +-- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/clusterman/kubernetes/kubernetes_cluster_connector.py b/clusterman/kubernetes/kubernetes_cluster_connector.py index 4a4c3dfd1..b03fc948d 100644 --- a/clusterman/kubernetes/kubernetes_cluster_connector.py +++ b/clusterman/kubernetes/kubernetes_cluster_connector.py @@ -24,8 +24,8 @@ import colorlog import kubernetes import staticconf +from kubernetes.client import V1beta1Eviction from kubernetes.client import V1DeleteOptions -from kubernetes.client import V1Eviction from kubernetes.client import V1ObjectMeta from kubernetes.client.models.v1_node import V1Node as KubernetesNode from kubernetes.client.models.v1_pod import V1Pod as KubernetesPod @@ -356,7 +356,7 @@ def _evict_pod(self, pod: KubernetesPod): self._core_api.create_namespaced_pod_eviction( name=pod.metadata.name, namespace=pod.metadata.namespace, - body=V1Eviction( + body=V1beta1Eviction( metadata=V1ObjectMeta( name=pod.metadata.name, namespace=pod.metadata.namespace, diff --git a/clusterman/kubernetes/util.py b/clusterman/kubernetes/util.py index 4fed406b7..0e9253a5f 100644 --- a/clusterman/kubernetes/util.py +++ b/clusterman/kubernetes/util.py @@ -30,7 +30,6 @@ from kubernetes.client.models.v1_node_selector_requirement import V1NodeSelectorRequirement from kubernetes.client.models.v1_node_selector_term import V1NodeSelectorTerm from kubernetes.client.models.v1_pod import V1Pod as KubernetesPod -from kubernetes.config.config_exception import ConfigException from clusterman.util import ClustermanResources @@ -73,7 +72,7 @@ def __init__(self, kubeconfig_path: str, client_class: Type) -> None: kubernetes.config.load_incluster_config() else: kubernetes.config.load_kube_config(kubeconfig_path, context=os.getenv("KUBECONTEXT")) - except (TypeError, ConfigException): + except TypeError: error_msg = "Could not load KUBECONFIG; is this running on Kubernetes master?" if "yelpcorp" in socket.getfqdn(): error_msg += "\nHint: try using the clusterman-k8s- wrapper script!" diff --git a/requirements.txt b/requirements.txt index e0308153d..8e4359b62 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,7 +16,7 @@ idna==2.8 jmespath==0.9.4 jsonpickle==1.4.2 kiwisolver==1.1.0 -kubernetes==24.2.0 +kubernetes==10.0.1 matplotlib==3.4.2 mypy-extensions==0.4.3 numpy==1.21.6 diff --git a/tests/kubernetes/util_test.py b/tests/kubernetes/util_test.py index 92942f9ac..3316a4660 100644 --- a/tests/kubernetes/util_test.py +++ b/tests/kubernetes/util_test.py @@ -5,7 +5,6 @@ import pytest from kubernetes.client.models.v1_node_selector_requirement import V1NodeSelectorRequirement from kubernetes.client.models.v1_node_selector_term import V1NodeSelectorTerm -from kubernetes.config import ConfigException from clusterman.kubernetes.util import CachedCoreV1Api from clusterman.kubernetes.util import ConciseCRDApi @@ -22,7 +21,7 @@ def mock_cached_core_v1_api(): def test_cached_corev1_api_no_kubeconfig(caplog): - with pytest.raises(ConfigException): + with pytest.raises(TypeError): CachedCoreV1Api("/foo/bar/admin.conf") assert "Could not load KUBECONFIG" in caplog.text