Skip to content

Commit 85b5f15

Browse files
committed
feat(deployment): update deployctl to disallow deleting prod
1 parent a1dcb97 commit 85b5f15

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

deploy/deployctl/subcommands/browser_deployments.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import string
66
import sys
77
import typing
8+
import time
89

910
from deployctl.config import config
1011
from deployctl.shell import kubectl, get_most_recent_tag, image_exists, get_k8s_deployments
@@ -235,6 +236,22 @@ def apply_deployment(name: str) -> None:
235236

236237

237238
def delete_deployment(name: str, clean: bool = False) -> None:
239+
try:
240+
active_prod = get_current_browser_deployment()
241+
except Exception as err: # pylint: disable=broad-except
242+
active_prod = None
243+
sleep_time = 30
244+
print(f"Warning: Could not determine active production deployment. Error: ({err})", file=sys.stderr)
245+
print(
246+
f"Sleeping for {sleep_time}s before proceeding with deletion. Cancel now with 'ctrl + c' unless you are SURE you want to proceed and delete deployment '{name}'."
247+
)
248+
time.sleep(sleep_time)
249+
250+
if active_prod and name == active_prod:
251+
raise RuntimeError(
252+
f"Warning: '{name}' is currently serving production. Quitting before deletion command is issued."
253+
)
254+
238255
deployment_directory = os.path.join(deployments_directory(), name)
239256

240257
if os.path.exists(deployment_directory):

0 commit comments

Comments
 (0)