Skip to content

Commit

Permalink
Adding try catch for k8s 1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
wilmer05 committed Jul 18, 2023
1 parent 4089f81 commit 35a5451
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions paasta_tools/setup_kubernetes_crd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import service_configuration_lib
from kubernetes.client import V1beta1CustomResourceDefinition
from kubernetes.client import V1CustomResourceDefinition
from kubernetes.client.exceptions import ApiException

from paasta_tools.kubernetes_tools import KubeClient
from paasta_tools.kubernetes_tools import paasta_prefixed
Expand Down Expand Up @@ -105,11 +106,18 @@ def setup_kube_crd(
label_selector=paasta_prefixed("service")
)

existing_crds_v1_beta1 = (
kube_client.apiextensions_v1_beta1.list_custom_resource_definition(
label_selector=paasta_prefixed("service")
# This step can fail in k8s 1.22 since this version is not existing anymore
# we need to support this for the transition
try:
existing_crds_v1_beta1 = (
kube_client.apiextensions_v1_beta1.list_custom_resource_definition(
label_selector=paasta_prefixed("service")
)
)
)
except ApiException as e:
existing_crds_v1_beta1 = []
log.debug(e)

desired_crds = []
desired_crds_v1_beta_1 = []
for service in services:
Expand Down

0 comments on commit 35a5451

Please sign in to comment.