Skip to content

Commit 785c01f

Browse files
Don't allow Friday deploys in Chrome. (#4513)
This was requested by Chrome in b/384493595. With more team members joining, I think it's best to enforce this policy, than expect everyone to know it.
1 parent c207151 commit 785c01f

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/local/butler/deploy.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import tempfile
2424
import time
2525

26+
import pytz
27+
2628
from local.butler import appengine
2729
from local.butler import common
2830
from local.butler import constants
@@ -47,9 +49,9 @@
4749
Version = namedtuple('Version', ['id', 'deploy_time', 'traffic_split'])
4850

4951

50-
def now():
52+
def now(tz=None):
5153
"""Used for mocks."""
52-
return datetime.datetime.now()
54+
return datetime.datetime.now(tz)
5355

5456

5557
def _get_services(paths):
@@ -449,6 +451,27 @@ def _deploy_terraform(config_dir):
449451
common.execute(f'rm -rf {terraform_dir}/.terraform*')
450452

451453

454+
def _is_safe_deploy_day():
455+
time_now_in_ny = now(pytz.timezone('America/New_York'))
456+
day_now_in_ny = time_now_in_ny.weekday()
457+
return day_now_in_ny not in {4, 5, 6} # The days of the week are 0-indexed.
458+
459+
460+
def _enforce_safe_day_to_deploy():
461+
"""Checks that is not an unsafe day (Friday, Saturday, or Sunday) to
462+
deploy for chrome ClusterFuzz."""
463+
464+
config = local_config.Config()
465+
if config.get('weekend_deploy_allowed', True):
466+
return
467+
468+
if not _is_safe_deploy_day():
469+
raise RuntimeError('Cannot deploy Fri-Sun to this CF instance except for '
470+
'urgent fixes. See b/384493595. If needed, temporarily '
471+
'delete+commit this. You are not too l33t for this '
472+
'rule. Do not break it!')
473+
474+
452475
def _deploy_k8s(config_dir):
453476
"""Deploys all k8s workloads."""
454477
k8s_dir = os.path.join('infra', 'k8s')
@@ -498,6 +521,8 @@ def execute(args):
498521
print('gsutil not found in PATH.')
499522
sys.exit(1)
500523

524+
_enforce_safe_day_to_deploy()
525+
501526
# Build templates before deployment.
502527
appengine.build_templates()
503528

0 commit comments

Comments
 (0)