Recipe: Add timeout for fetching gerrit commit message in tryserver API

In crbug.com/1196159, a build got stuck at "gerrit changes" step for 3
hours. It would be good to add a timeout so that it fails early.

Also adjust the timeout for get_changes to 60s, from 600s

Bug: 1196159
Change-Id: Id2327ab40dd2fd8d95aaad6bb724f7ed06e6c244
Recipe-Nontrivial-Roll: infra
Recipe-Nontrivial-Roll: chromiumos
Recipe-Nontrivial-Roll: build_limited_scripts_slave
Recipe-Nontrivial-Roll: build
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2811899
Commit-Queue: Haiyang Pan <hypan@google.com>
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
This commit is contained in:
Haiyang Pan
2021-04-10 00:11:10 +00:00
committed by LUCI CQ
parent b2c07b2300
commit 057831ef1f
19 changed files with 49 additions and 32 deletions

View File

@@ -68,7 +68,12 @@ class GerritApi(recipe_api.RecipeApi):
revision = step_result.json.output.get('revision')
return revision
def get_change_description(self, host, change, patchset, step_test_data=None):
def get_change_description(self,
host,
change,
patchset,
timeout=None,
step_test_data=None):
"""Gets the description for a given CL and patchset.
Args:
@@ -79,10 +84,15 @@ class GerritApi(recipe_api.RecipeApi):
Returns:
The description corresponding to given CL and patchset.
"""
ri = self.get_revision_info(host, change, patchset, step_test_data)
ri = self.get_revision_info(host, change, patchset, timeout, step_test_data)
return ri['commit']['message']
def get_revision_info(self, host, change, patchset, step_test_data=None):
def get_revision_info(self,
host,
change,
patchset,
timeout=None,
step_test_data=None):
"""
Returns the info for a given patchset of a given change.
@@ -106,6 +116,7 @@ class GerritApi(recipe_api.RecipeApi):
query_params=[('change', str(change))],
o_params=['ALL_REVISIONS', 'ALL_COMMITS'],
limit=1,
timeout=timeout,
step_test_data=step_test_data)
cl = cls[0] if len(cls) == 1 else {'revisions': {}}
for ri in cl['revisions'].values():