From 23a8e38d9b5586068d3e3c9362170299bd2ca6e6 Mon Sep 17 00:00:00 2001 From: Jonathan Metzman Date: Mon, 16 Dec 2024 22:30:41 -0500 Subject: [PATCH 1/2] Dont' allow Friday deploys in Chrome. This was requested by Chrome in b/384493595. --- src/local/butler/deploy.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/local/butler/deploy.py b/src/local/butler/deploy.py index 0898ba0c06..90353c6f92 100644 --- a/src/local/butler/deploy.py +++ b/src/local/butler/deploy.py @@ -23,6 +23,8 @@ import tempfile import time +import pytz + from local.butler import appengine from local.butler import common from local.butler import constants @@ -47,9 +49,9 @@ Version = namedtuple('Version', ['id', 'deploy_time', 'traffic_split']) -def now(): +def now(tz=None): """Used for mocks.""" - return datetime.datetime.now() + return datetime.datetime.now(tz) def _get_services(paths): @@ -449,6 +451,27 @@ def _deploy_terraform(config_dir): common.execute(f'rm -rf {terraform_dir}/.terraform*') +def _is_safe_deploy_day(): + time_now_in_ny = now(pytz.timezone('America/New_York')) + day_now_in_ny = time_now_in_ny.weekday() + return day_now_in_ny not in {4, 5, 6} # The days of the week are 0-indexed. + + +def _enforce_safe_day_to_deploy(): + """Checks that is not an unsafe day (Friday, Saturday, or Sunday) to + deploy for chrome ClusterFuzz.""" + + config = local_config.Config() + if config.get('weekend_deploy_allowed', True): + return + + if not _is_safe_deploy_day(): + raise RuntimeError('Cannot deploy Fri-Sun to this CF instance except for ' + 'urgent fixes. See b/384493595. If needed, temporarily ' + 'delete+commit this. You are not too l33t for this ' + 'rule. Do not break it!') + + def _deploy_k8s(config_dir): """Deploys all k8s workloads.""" k8s_dir = os.path.join('infra', 'k8s') From a6b51d81dd3f9b3fd9b793236a390948f9f07c1c Mon Sep 17 00:00:00 2001 From: Jonathan Metzman Date: Mon, 16 Dec 2024 23:01:30 -0500 Subject: [PATCH 2/2] fix --- src/local/butler/deploy.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/local/butler/deploy.py b/src/local/butler/deploy.py index 90353c6f92..444a82a5c8 100644 --- a/src/local/butler/deploy.py +++ b/src/local/butler/deploy.py @@ -521,6 +521,8 @@ def execute(args): print('gsutil not found in PATH.') sys.exit(1) + _enforce_safe_day_to_deploy() + # Build templates before deployment. appengine.build_templates()