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 adade08
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 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,37 @@ 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_response = api_instance.delete_custom_resource_definition(
name="workflowtasksets.argoproj.io",
)
except kubernetes.client.exceptions.ApiException as e:
print(e)
else:
print(api_response.metadata)

namespace = config.get("namespace", "default")
for sa in argo_sa:
api_instance = kubernetes.client.CoreV1Api()
try:
api_response = api_instance.delete_namespaced_service_account(
sa,
namespace,
)
except kubernetes.client.exceptions.ApiException as e:
print(e)
else:
print(api_response.metadata)
else:
kubectl_delete_argo_crds_cmd = " ".join(
(
Expand Down

0 comments on commit adade08

Please sign in to comment.