multi_roller: Suppress failure to vote -1
Suppress errors that result from failing to vote -1 on changes. These
errors result from changes already being abandoned because they failed
presubmits.
Change-Id: I8fcccd77b601163e7972c99c862f2bfcf9f0b687
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/241013
Reviewed-by: Samuel Liu <slliu@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
diff --git a/recipes/multi_roller.py b/recipes/multi_roller.py
index db4d248..f38caea 100644
--- a/recipes/multi_roller.py
+++ b/recipes/multi_roller.py
@@ -113,16 +113,25 @@
# Add Rolls-Synced label value on roll CLs.
roll_sync_label_value = 1 if presubmits_passed else -1
for change in roller_changes:
- api.gerrit.set_review(
- name=(
- f"Set {props.rolls_synced_label} {roll_sync_label_value:+} "
- f"on {change.change_id}"
- ),
- change_id=change.change_id,
- labels={props.rolls_synced_label: roll_sync_label_value},
- host=change.host,
- test_data=api.json.test_api.output({}),
- )
+ try:
+ api.gerrit.set_review(
+ name=(
+ f"Set {props.rolls_synced_label} "
+ f"{roll_sync_label_value:+} on {change.change_id}"
+ ),
+ change_id=change.change_id,
+ labels={props.rolls_synced_label: roll_sync_label_value},
+ host=change.host,
+ test_data=api.json.test_api.output({}),
+ )
+
+ except api.step.StepFailure: # pragma: no cover
+ # If there's an error setting a label on a change it's likely
+ # because the change has already been abandoned. Don't surface
+ # this error unless the change has passed, in which case the
+ # change should not be abandoned.
+ if presubmits_passed:
+ raise
# Raise failure if presubmits failed
if not presubmits_passed: