Skip to content

Commit

Permalink
Set up minimal functionality for deleting CRDs and SAs
Browse files Browse the repository at this point in the history
  • Loading branch information
smokestacklightnin committed Nov 21, 2024
1 parent 239c419 commit d7520ed
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/_nebari/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,6 @@ def _version_specific_upgrade(
"""
Prompt users to delete Argo CRDs
"""

argo_crds = [
"clusterworkflowtemplates.argoproj.io",
"cronworkflows.argoproj.io",
Expand All @@ -663,7 +662,35 @@ def _version_specific_upgrade(
argo_sa = ["argo-admin", "argo-dev", "argo-view"]

if kwargs.get("attempt_fixes", False):
pass
try:
kubernetes.config.load_kube_config()
except kubernetes.config.config_exception.ConfigException:
rich.print(
"[red bold]No default kube configuration file was found. Make sure to [link=https://www.nebari.dev/docs/how-tos/debug-nebari#generating-the-kubeconfig]have one pointing to your Nebari cluster[/link] before upgrading.[/red bold]"
)
exit()

for crd in argo_crds:
api_instance = kubernetes.client.ApiextensionsV1Api()
try:
api_instance.delete_custom_resource_definition(
name=crd,
)
except kubernetes.client.exceptions.ApiException as e:
if e.status != 404:
raise e

namespace = config.get("namespace", "default")
for sa in argo_sa:
api_instance = kubernetes.client.CoreV1Api()
try:
api_instance.delete_namespaced_service_account(
sa,
namespace,
)
except kubernetes.client.exceptions.ApiException as e:
if e.status != 404:
raise e
else:
kubectl_delete_argo_crds_cmd = " ".join(
(
Expand Down

0 comments on commit d7520ed

Please sign in to comment.