Skip to content

Commit

Permalink
s/V1beta1PodDisruptionBudget/V1PodDisruptionBudget/ for COMPINFRA-4409
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanKrall committed Dec 3, 2024
1 parent ef0195f commit 19968c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions paasta_tools/kubernetes/application/controller_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from typing import Optional
from typing import Union

from kubernetes.client import V1beta1PodDisruptionBudget
from kubernetes.client import V1DeleteOptions
from kubernetes.client import V1Deployment
from kubernetes.client import V1PodDisruptionBudget
from kubernetes.client import V1StatefulSet
from kubernetes.client.rest import ApiException

Expand Down Expand Up @@ -168,7 +168,7 @@ def delete_pod_disruption_budget(self, kube_client: KubeClient) -> None:

def ensure_pod_disruption_budget(
self, kube_client: KubeClient, namespace: str
) -> V1beta1PodDisruptionBudget:
) -> V1PodDisruptionBudget:
max_unavailable: Union[str, int]
if "bounce_margin_factor" in self.soa_config.config_dict:
max_unavailable = (
Expand Down
20 changes: 10 additions & 10 deletions paasta_tools/kubernetes_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
from kubernetes.client import models
from kubernetes.client import V1Affinity
from kubernetes.client import V1AWSElasticBlockStoreVolumeSource
from kubernetes.client import V1beta1PodDisruptionBudget
from kubernetes.client import V1beta1PodDisruptionBudgetSpec
from kubernetes.client import V1Capabilities
from kubernetes.client import V1ConfigMap
from kubernetes.client import V1Container
Expand Down Expand Up @@ -92,6 +90,8 @@
from kubernetes.client import V1PodAffinityTerm
from kubernetes.client import V1PodAntiAffinity
from kubernetes.client import V1PodCondition
from kubernetes.client import V1PodDisruptionBudget
from kubernetes.client import V1PodDisruptionBudgetSpec
from kubernetes.client import V1PodSecurityContext
from kubernetes.client import V1PodSpec
from kubernetes.client import V1PodTemplateSpec
Expand Down Expand Up @@ -318,7 +318,7 @@ class DatastoreCredentialsConfig(TypedDict, total=False):


def _set_disrupted_pods(self: Any, disrupted_pods: Mapping[str, datetime]) -> None:
"""Private function used to patch the setter for V1beta1PodDisruptionBudgetStatus.
"""Private function used to patch the setter for V1PodDisruptionBudgetStatus.
Can be removed once https://github.com/kubernetes-client/python/issues/466 is resolved
"""
self._disrupted_pods = disrupted_pods
Expand Down Expand Up @@ -582,8 +582,8 @@ def __init__(
context=context,
)

models.V1beta1PodDisruptionBudgetStatus.disrupted_pods = property(
fget=lambda *args, **kwargs: models.V1beta1PodDisruptionBudgetStatus.disrupted_pods(
models.V1PodDisruptionBudgetStatus.disrupted_pods = property(
fget=lambda *args, **kwargs: models.V1PodDisruptionBudgetStatus.disrupted_pods(
*args, **kwargs
),
fset=_set_disrupted_pods,
Expand All @@ -603,7 +603,7 @@ def __init__(

self.deployments = kube_client.AppsV1Api(self.api_client)
self.core = kube_client.CoreV1Api(self.api_client)
self.policy = kube_client.PolicyV1beta1Api(self.api_client)
self.policy = kube_client.PolicyV1Api(self.api_client)
self.apiextensions = kube_client.ApiextensionsV1Api(self.api_client)

self.custom = kube_client.CustomObjectsApi(self.api_client)
Expand Down Expand Up @@ -3190,13 +3190,13 @@ def pod_disruption_budget_for_service_instance(
instance: str,
max_unavailable: Union[str, int],
namespace: str,
) -> V1beta1PodDisruptionBudget:
return V1beta1PodDisruptionBudget(
) -> V1PodDisruptionBudget:
return V1PodDisruptionBudget(
metadata=V1ObjectMeta(
name=get_kubernetes_app_name(service, instance),
namespace=namespace,
),
spec=V1beta1PodDisruptionBudgetSpec(
spec=V1PodDisruptionBudgetSpec(
max_unavailable=max_unavailable,
selector=V1LabelSelector(
match_labels={
Expand All @@ -3210,7 +3210,7 @@ def pod_disruption_budget_for_service_instance(

def create_pod_disruption_budget(
kube_client: KubeClient,
pod_disruption_budget: V1beta1PodDisruptionBudget,
pod_disruption_budget: V1PodDisruptionBudget,
namespace: str,
) -> None:
return kube_client.policy.create_namespaced_pod_disruption_budget(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_kubernetes_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from kubernetes import client as kube_client
from kubernetes.client import V1Affinity
from kubernetes.client import V1AWSElasticBlockStoreVolumeSource
from kubernetes.client import V1beta1PodDisruptionBudget
from kubernetes.client import V1Capabilities
from kubernetes.client import V1Container
from kubernetes.client import V1ContainerPort
Expand All @@ -41,6 +40,7 @@
from kubernetes.client import V1PersistentVolumeClaimSpec
from kubernetes.client import V1PodAffinityTerm
from kubernetes.client import V1PodAntiAffinity
from kubernetes.client import V1PodDisruptionBudget
from kubernetes.client import V1PodSpec
from kubernetes.client import V1PodTemplateSpec
from kubernetes.client import V1PreferredSchedulingTerm
Expand Down Expand Up @@ -3440,7 +3440,7 @@ def test_pod_disruption_budget_for_service_instance():

def test_create_pod_disruption_budget():
mock_client = mock.Mock()
mock_pdr = V1beta1PodDisruptionBudget()
mock_pdr = V1PodDisruptionBudget()
mock_namespace = "paasta"
create_pod_disruption_budget(mock_client, mock_pdr, mock_namespace)
mock_client.policy.create_namespaced_pod_disruption_budget.assert_called_with(
Expand Down

0 comments on commit 19968c2

Please sign in to comment.