Commit cb326681 authored by Stephen Martinis's avatar Stephen Martinis Committed by Commit Bot

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/1191927Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Stephen Martinis <martiniss@chromium.org>
parent 9342ac02
......@@ -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')
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment