blob: 050d9d12c444f8fd0e965e826d113e8094affca5 [file] [log] [blame]
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
DRONE_TIMEOUT_SECS = 3600 * 3 # 3 hours.
from recipe_engine import recipe_api
from import common as common_pb2
# Builder names use full platform name instead of short names. We need to
# map short names to full platform names to be able to identify the drone
# used to run the subshards.
PLATFORM_TO_NAME = {'win': 'Windows', 'linux': 'Linux', 'mac': 'Mac'}
class ShardUtilApi(recipe_api.RecipeApi):
"""Utilities to shard tasks."""
def schedule_builds(self):
"""Schedules one subbuild per subshard."""
reqs = []
# Dependencies get here as a frozen dict we need force them back to list of
# dicts.
deps ='dependencies', [])
deps_list = [{'dependency': d['dependency']} for d in deps]
for subshard in'subshards'):
task_name = '%s-%s' % ('shard', ''), subshard)
drone_props = {
subshard, 'shard':'shard', ''), 'android_sdk_license':'android_sdk_license', ''),
''), 'dependencies':
deps_list, 'task_name':
drone_props['git_url'] ='git_url')
drone_props['git_ref'] ='git_ref')
drone_props['$depot_tools/osx_sdk'] = {
drone_props['$flutter/osx_sdk'] = {
# Drone_dimensions property from the parent builder will override the
# default drone properties if not empty.
drone_dimensions ='drone_dimensions', [])
task_dimensions = []
for d in drone_dimensions:
k, v = d.split('=')
task_dimensions.append(common_pb2.RequestedDimension(key=k, value=v))
platform_name = PLATFORM_TO_NAME.get(
req = self.m.buildbucket.schedule_request(
builder='%s SDK Drone' % platform_name,
dimensions=task_dimensions or None,
# Having main build and subbuilds with the same priority can lead
# to a deadlock situation when there are limited resources. For example
# if we have only 7 mac bots and we get more than 7 new build requests the
# within minutes of each other then the 7 bots will be used by main tasks
# and they will all timeout waiting for resources to run subbuilds.
# Increasing priority won't fix the problem but will make the deadlock
# situation less unlikely.
priority=25,'exe_cipd_version', 'refs/heads/main')
return self.m.buildbucket.schedule(reqs)
def collect_builds(self, builds):
"""Waits for a list of builds to complete.
step = self.m.step('Task Shards', None)
for build in builds:
task_name =['task_name'].string_value
step.presentation.links[task_name] = self.m.buildbucket.build_url(
bb_fields = self.m.buildbucket.DEFAULT_FIELDS.union({"summary_markdown"})
return self.m.buildbucket.collect_builds([ for build in builds],