Skip to content

Commit

Permalink
Refactor Argo delete commands
Browse files Browse the repository at this point in the history
  • Loading branch information
smokestacklightnin committed Nov 19, 2024
1 parent c6cc665 commit 4807612
Showing 1 changed file with 42 additions and 16 deletions.
58 changes: 42 additions & 16 deletions src/_nebari/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,26 +651,52 @@ def _version_specific_upgrade(
Prompt users to delete Argo CRDs
"""

kubectl_delete_argo_crds_cmd = "kubectl delete crds clusterworkflowtemplates.argoproj.io cronworkflows.argoproj.io workfloweventbindings.argoproj.io workflows.argoproj.io workflowtasksets.argoproj.io workflowtemplates.argoproj.io"

kubectl_delete_argo_sa_cmd = (
f"kubectl delete sa -n {config['namespace']} argo-admin argo-dev argo-view"
)
argo_crds = [
"clusterworkflowtemplates.argoproj.io",
"cronworkflows.argoproj.io",
"workfloweventbindings.argoproj.io",
"workflows.argoproj.io",
"workflowtasksets.argoproj.io",
"workflowtemplates.argoproj.io",
]

rich.print(
f"\n\n[bold cyan]Note:[/] Upgrading requires a one-time manual deletion of the Argo Workflows Custom Resource Definitions (CRDs) and service accounts. \n\n[red bold]Warning: [link=https://{config['domain']}/argo/workflows]Workflows[/link] and [link=https://{config['domain']}/argo/workflows]CronWorkflows[/link] created before deleting the CRDs will be erased when the CRDs are deleted and will not be restored.[/red bold] \n\nThe updated CRDs will be installed during the next [cyan bold]nebari deploy[/cyan bold] step. Argo Workflows will not function after deleting the CRDs until the updated CRDs and service accounts are installed in the next nebari deploy. You must delete the Argo Workflows CRDs and service accounts before upgrading to {self.version} (or later) or the deploy step will fail. Please delete them before proceeding by generating a kubeconfig (see [link=https://www.nebari.dev/docs/how-tos/debug-nebari/#generating-the-kubeconfig]docs[/link]), installing kubectl (see [link=https://www.nebari.dev/docs/how-tos/debug-nebari#installing-kubectl]docs[/link]), and running the following two commands:\n\n\t[cyan bold]{kubectl_delete_argo_crds_cmd} [/cyan bold]\n\n\t[cyan bold]{kubectl_delete_argo_sa_cmd} [/cyan bold]"
""
)
argo_sa = ["argo-admin", "argo-dev", "argo-view"]

continue_ = kwargs.get("attempt_fixes", False) or Confirm.ask(
"Have you deleted the Argo Workflows CRDs and service accounts?",
default=False,
)
if not continue_:
if kwargs.get("attempt_fixes", False):
...
else:
kubectl_delete_argo_crds_cmd = " ".join(
(
*("kubectl delete crds",),
*argo_crds,
),
)
kubectl_delete_argo_sa_cmd = " ".join(
(
*(
"kubectl delete sa",
f"-n {config.get("namespace", "default")}",
),
*argo_sa,
),
)
rich.print(
f"You must delete the Argo Workflows CRDs and service accounts before upgrading to [green]{self.version}[/green] (or later)."
f"\n\n[bold cyan]Note:[/] Upgrading requires a one-time manual deletion of the Argo Workflows Custom Resource Definitions (CRDs) and service accounts. \n\n[red bold]"
f"Warning: [link=https://{config['domain']}/argo/workflows]Workflows[/link] and [link=https://{config['domain']}/argo/workflows]CronWorkflows[/link] created before deleting the CRDs will be erased when the CRDs are deleted and will not be restored.[/red bold] \n\n"
f"The updated CRDs will be installed during the next [cyan bold]nebari deploy[/cyan bold] step. Argo Workflows will not function after deleting the CRDs until the updated CRDs and service accounts are installed in the next nebari deploy. "
f"You must delete the Argo Workflows CRDs and service accounts before upgrading to {self.version} (or later) or the deploy step will fail. "
f"Please delete them before proceeding by generating a kubeconfig (see [link=https://www.nebari.dev/docs/how-tos/debug-nebari/#generating-the-kubeconfig]docs[/link]), installing kubectl (see [link=https://www.nebari.dev/docs/how-tos/debug-nebari#installing-kubectl]docs[/link]), and running the following two commands:\n\n\t[cyan bold]{kubectl_delete_argo_crds_cmd} [/cyan bold]\n\n\t[cyan bold]{kubectl_delete_argo_sa_cmd} [/cyan bold]"
)
exit()

continue_ = Confirm.ask(
"Have you deleted the Argo Workflows CRDs and service accounts?",
default=False,
)
if not continue_:
rich.print(
f"You must delete the Argo Workflows CRDs and service accounts before upgrading to [green]{self.version}[/green] (or later)."
)
exit()

return config

Expand Down

0 comments on commit 4807612

Please sign in to comment.