From cb32668137d08ec52ee893a872df3a61903215a2 Mon Sep 17 00:00:00 2001 From: Stephen Martinis Date: Wed, 29 Aug 2018 21:06:30 +0000 Subject: [PATCH] git cl split: Don't cq dry run by default `git cl split` currently runs a cq dry run for every uploaded CL. This has overloaded our infrastructure a few times in the past. This CL changes the command to not dry run by default, and adds a flag to enable this. The flag has a warning about doing this, and tells the user to email infra-dev@chromium.org if they're going to be generating >~10 CLs. Bug: 878117 Change-Id: Ic865c09b188b8d4f202785f4763f7b7b8910c9cf Reviewed-on: https://chromium-review.googlesource.com/1191927 Reviewed-by: Andrii Shyshkalov Reviewed-by: Edward Lesmes Commit-Queue: Stephen Martinis --- git_cl.py | 10 +++++++++- split_cl.py | 25 +++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/git_cl.py b/git_cl.py index a98107b02..500641ecb 100755 --- a/git_cl.py +++ b/git_cl.py @@ -5142,6 +5142,13 @@ def CMDsplit(parser, args): default=False, help="List the files and reviewers for each CL that would " "be created, but don't create branches or CLs.") + parser.add_option("--cq-dry-run", action='store_true', + help="If set, will do a cq dry run for each uploaded CL. " + "Please be careful when doing this; more than ~10 CLs " + "has the potential to overload our build " + "infrastructure. Try to upload these not during high " + "load times (usually 11-3 Mountain View time). Email " + "infra-dev@chromium.org with any questions.") options, _ = parser.parse_args(args) if not options.description_file: @@ -5151,7 +5158,8 @@ def CMDsplit(parser, args): return CMDupload(OptionParser(), args) return split_cl.SplitCl(options.description_file, options.comment_file, - Changelist, WrappedCMDupload, options.dry_run) + Changelist, WrappedCMDupload, options.dry_run, + options.cq_dry_run) @subcommand.usage('DEPRECATED') diff --git a/split_cl.py b/split_cl.py index 32203fc57..05c682e1c 100644 --- a/split_cl.py +++ b/split_cl.py @@ -67,7 +67,8 @@ def AddUploadedByGitClSplitToDescription(description): def UploadCl(refactor_branch, refactor_branch_upstream, directory, files, - description, comment, reviewers, changelist, cmd_upload): + description, comment, reviewers, changelist, cmd_upload, + cq_dry_run): """Uploads a CL with all changes to |files| in |refactor_branch|. Args: @@ -81,6 +82,7 @@ def UploadCl(refactor_branch, refactor_branch_upstream, directory, files, reviewers: A set of reviewers for the CL. changelist: The Changelist class. cmd_upload: The function associated with the git cl upload command. + cq_dry_run: If CL uploads should also do a cq dry run. """ # Create a branch. if not CreateBranchForDirectory( @@ -107,7 +109,9 @@ def UploadCl(refactor_branch, refactor_branch_upstream, directory, files, os.remove(tmp_file.name) # Upload a CL. - upload_args = ['-f', '--cq-dry-run', '-r', ','.join(reviewers)] + upload_args = ['-f', '-r', ','.join(reviewers)] + if cq_dry_run: + upload_args.append('--cq-dry-run') if not comment: upload_args.append('--send-mail') print 'Uploading CL for ' + directory + '.' @@ -156,7 +160,8 @@ def PrintClInfo(cl_index, num_cls, directory, file_paths, description, print -def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run): +def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run, + cq_dry_run): """"Splits a branch into smaller branches and uploads CLs. Args: @@ -165,6 +170,7 @@ def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run): changelist: The Changelist class. cmd_upload: The function associated with the git cl upload command. dry_run: Whether this is a dry run (no branches or CLs created). + cq_dry_run: If CL uploads should also do a cq dry run. Returns: 0 in case of success. 1 in case of error. @@ -198,6 +204,16 @@ def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run): num_cls = len(files_split_by_owners) print('Will split current branch (' + refactor_branch + ') into ' + str(num_cls) + ' CLs.\n') + if cq_dry_ru and num_cls > CL_SPLIT_FORCE_LIMIT: + print ( + 'This will generate "%r" CLs. This many CLs can potentially generate' + ' too much load on the build infrastructure. Please email' + ' infra-dev@chromium.org to ensure that this won\'t break anything.' + ' The infra team reserves the right to cancel your jobs if they are' + ' overloading the CQ.') % num_cls + answer = raw_input('Proceed? (y/n):') + if answer.lower() != 'y': + return 0 for cl_index, (directory, files) in \ enumerate(files_split_by_owners.iteritems(), 1): @@ -212,7 +228,8 @@ def SplitCl(description_file, comment_file, changelist, cmd_upload, dry_run): reviewers) else: UploadCl(refactor_branch, refactor_branch_upstream, directory, files, - description, comment, reviewers, changelist, cmd_upload) + description, comment, reviewers, changelist, cmd_upload, + cq_dry_run) # Go back to the original branch. git.run('checkout', refactor_branch)