Add mechanism for telling CQ to avoid retrying builds.

The function can be called by chromium_test to set a property 'do_not_retry'
which will be propagated into buildbucket output.

Change-Id: I32d8ea925b7cb98d9b25d24226686e116c17801c
Bug: 910193
Reviewed-on: https://chromium-review.googlesource.com/c/1351542
Commit-Queue: Erik Chen <erikchen@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: Ben Pastene <bpastene@chromium.org>
changes/42/1351542/7
erikchen 6 years ago committed by Commit Bot
parent 457b44f3cd
commit 016601cc21

@ -751,7 +751,7 @@ Return a presubmit step.
#### **class [TryserverApi](/recipes/recipe_modules/tryserver/api.py#11)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
&mdash; **def [add\_failure\_reason](/recipes/recipe_modules/tryserver/api.py#206)(self, reason):**
&mdash; **def [add\_failure\_reason](/recipes/recipe_modules/tryserver/api.py#215)(self, reason):**
Records a more detailed reason why build is failing.
@ -791,11 +791,11 @@ Argument:
Returned paths will be relative to to patch_root.
&mdash; **def [get\_footer](/recipes/recipe_modules/tryserver/api.py#262)(self, tag, patch_text=None):**
&mdash; **def [get\_footer](/recipes/recipe_modules/tryserver/api.py#271)(self, tag, patch_text=None):**
Gets a specific tag from a CL description
&mdash; **def [get\_footers](/recipes/recipe_modules/tryserver/api.py#242)(self, patch_text=None):**
&mdash; **def [get\_footers](/recipes/recipe_modules/tryserver/api.py#251)(self, patch_text=None):**
Retrieves footers from the patch description.
@ -814,13 +814,20 @@ Returns true iff the properties exist to match a Gerrit issue.
Returns true iff we have a change to check out.
&mdash; **def [normalize\_footer\_name](/recipes/recipe_modules/tryserver/api.py#266)(self, footer):**
&mdash; **def [normalize\_footer\_name](/recipes/recipe_modules/tryserver/api.py#275)(self, footer):**
&mdash; **def [set\_compile\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#185)(self):**
&mdash; **def [set\_compile\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#194)(self):**
Mark the tryjob result as a compile failure.
&emsp; **@contextlib.contextmanager**<br>&mdash; **def [set\_failure\_hash](/recipes/recipe_modules/tryserver/api.py#215)(self):**
&mdash; **def [set\_do\_not\_retry\_build](/recipes/recipe_modules/tryserver/api.py#181)(self):**
A flag to indicate the build should not be retried by the CQ.
This mechanism is used to reduce CQ duration when retrying will likely
return an identical result.
&emsp; **@contextlib.contextmanager**<br>&mdash; **def [set\_failure\_hash](/recipes/recipe_modules/tryserver/api.py#224)(self):**
Context manager that sets a failure_hash build property on StepFailure.
@ -829,7 +836,7 @@ for the same reason. For example, if a patch is bad (breaks something),
we'd expect it to always break in the same way. Different failures
for the same patch are usually a sign of flakiness.
&mdash; **def [set\_invalid\_test\_results\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#197)(self):**
&mdash; **def [set\_invalid\_test\_results\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#206)(self):**
Mark the tryjob result as having invalid test results.
@ -837,7 +844,7 @@ This means we run some tests, but the results were not valid
(e.g. no list of specific test cases that failed, or too many
tests failing, etc).
&mdash; **def [set\_patch\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#181)(self):**
&mdash; **def [set\_patch\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#190)(self):**
Mark the tryjob result as failure to apply the patch.
@ -848,7 +855,7 @@ Adds a subproject tag to the build.
This can be used to distinguish between builds that execute different steps
depending on what was patched, e.g. blink vs. pure chromium patches.
&mdash; **def [set\_test\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#189)(self):**
&mdash; **def [set\_test\_failure\_tryjob\_result](/recipes/recipe_modules/tryserver/api.py#198)(self):**
Mark the tryjob result as a test failure.

@ -178,6 +178,15 @@ class TryserverApi(recipe_api.RecipeApi):
step_result = self.m.step.active_result
step_result.presentation.properties['failure_type'] = failure_type
def set_do_not_retry_build(self):
"""A flag to indicate the build should not be retried by the CQ.
This mechanism is used to reduce CQ duration when retrying will likely
return an identical result.
"""
step_result = self.m.step.active_result
step_result.presentation.properties['do_not_retry'] = True
def set_patch_failure_tryjob_result(self):
"""Mark the tryjob result as failure to apply the patch."""
self._set_failure_type('PATCH_FAILURE')

@ -117,6 +117,7 @@
"~followup_annotations": [
"@@@STEP_LOG_LINE@files@None/foo.cc@@@",
"@@@STEP_LOG_END@files@@@",
"@@@SET_BUILD_PROPERTY@do_not_retry@true@@@",
"@@@SET_BUILD_PROPERTY@failure_type@\"INVALID_TEST_RESULTS\"@@@",
"@@@SET_BUILD_PROPERTY@subproject_tag@\"v8\"@@@"
]

@ -117,6 +117,7 @@
"~followup_annotations": [
"@@@STEP_LOG_LINE@files@None/foo.cc@@@",
"@@@STEP_LOG_END@files@@@",
"@@@SET_BUILD_PROPERTY@do_not_retry@true@@@",
"@@@SET_BUILD_PROPERTY@failure_type@\"INVALID_TEST_RESULTS\"@@@",
"@@@SET_BUILD_PROPERTY@subproject_tag@\"v8\"@@@"
]

@ -15,6 +15,7 @@
"~followup_annotations": [
"@@@STEP_LOG_LINE@files@v8/foo.cc@@@",
"@@@STEP_LOG_END@files@@@",
"@@@SET_BUILD_PROPERTY@do_not_retry@true@@@",
"@@@SET_BUILD_PROPERTY@failure_type@\"INVALID_TEST_RESULTS\"@@@",
"@@@SET_BUILD_PROPERTY@subproject_tag@\"v8\"@@@"
]

@ -15,6 +15,7 @@
"~followup_annotations": [
"@@@STEP_LOG_LINE@files@v8/foo.cc@@@",
"@@@STEP_LOG_END@files@@@",
"@@@SET_BUILD_PROPERTY@do_not_retry@true@@@",
"@@@SET_BUILD_PROPERTY@failure_type@\"INVALID_TEST_RESULTS\"@@@",
"@@@SET_BUILD_PROPERTY@subproject_tag@\"v8\"@@@"
]

@ -13,7 +13,8 @@
"stdout": "/path/to/tmp/",
"~followup_annotations": [
"@@@STEP_LOG_LINE@files@foo.cc@@@",
"@@@STEP_LOG_END@files@@@"
"@@@STEP_LOG_END@files@@@",
"@@@SET_BUILD_PROPERTY@do_not_retry@true@@@"
]
},
{

@ -14,7 +14,8 @@
"stdout": "/path/to/tmp/",
"~followup_annotations": [
"@@@STEP_LOG_LINE@files@sub/project/foo.cc@@@",
"@@@STEP_LOG_END@files@@@"
"@@@STEP_LOG_END@files@@@",
"@@@SET_BUILD_PROPERTY@do_not_retry@true@@@"
]
},
{

@ -46,6 +46,7 @@ def RunSteps(api):
api.tryserver.set_subproject_tag('v8')
api.tryserver.set_patch_failure_tryjob_result()
api.tryserver.set_do_not_retry_build()
api.tryserver.set_compile_failure_tryjob_result()
api.tryserver.set_test_failure_tryjob_result()
api.tryserver.set_invalid_test_results_tryjob_result()

Loading…
Cancel
Save