[auto_roller] Finalize even if "cc" step fails
If the "cc" step fails at the end of the roll still make sure the roll
CL gets abandoned or submitted.
Example failure: http://go/bbid/8806721144744987793
Change-Id: I8d93ba3df5fe035bfeacd8eb9824ba0e356c7cca
Reviewed-on: https://fuchsia-review.googlesource.com/c/infra/recipes/+/708065
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Ina Huh <ihuh@google.com>
diff --git a/recipe_modules/auto_roller/api.py b/recipe_modules/auto_roller/api.py
index 049e87e..4036518 100644
--- a/recipe_modules/auto_roller/api.py
+++ b/recipe_modules/auto_roller/api.py
@@ -361,31 +361,33 @@
change, opts.dry_run, opts.labels_to_set or {}, opts.labels_to_wait_on
)
- if not change.success and opts.cc_on_failure_emails:
- self.m.gerrit.set_review(
- "cc", change.id, ccs=opts.cc_on_failure_emails, host=change.host
- )
+ try:
+ if not change.success and opts.cc_on_failure_emails:
+ self.m.gerrit.set_review(
+ "cc", change.id, ccs=opts.cc_on_failure_emails, host=change.host
+ )
- # Interpret the result and finish.
- if opts.dry_run:
- # Only abandon the roll on success if it was a dry-run.
- self._ensure_abandoned(
- change,
- reason="dry run %s" % ("passed" if change.success else "failed"),
- notify_option=opts.cl_notify_option,
- clear_commit_queue=clear_commit_queue,
- )
- elif not change.success:
- self._ensure_abandoned(
- change,
- notify_option=opts.cl_notify_option,
- clear_commit_queue=clear_commit_queue,
- retrigger_link=True,
- )
- elif change.last_seen_status and change.last_seen_status != "MERGED":
- # For Gerrit hosts that do not use CQ, the roller itself must
- # handle submission.
- self._force_submit(change)
+ finally:
+ # Interpret the result and finish.
+ if opts.dry_run:
+ # Only abandon the roll on success if it was a dry-run.
+ self._ensure_abandoned(
+ change,
+ reason="dry run %s" % ("passed" if change.success else "failed"),
+ notify_option=opts.cl_notify_option,
+ clear_commit_queue=clear_commit_queue,
+ )
+ elif not change.success:
+ self._ensure_abandoned(
+ change,
+ notify_option=opts.cl_notify_option,
+ clear_commit_queue=clear_commit_queue,
+ retrigger_link=True,
+ )
+ elif change.last_seen_status and change.last_seen_status != "MERGED":
+ # For Gerrit hosts that do not use CQ, the roller itself must
+ # handle submission.
+ self._force_submit(change)
if raise_on_failure:
change.raise_if_failed()