[tools][cts] Abandon CTS roll CL after exhausting retries Previously, when the CTS autoroller exhausted its retry limit, it posted a comment on the Gerrit CL and exited, leaving the failed CL sitting in WIP. Update the roller to abandon the CL in Gerrit with the failure message instead. Change-Id: I40dc622a39117dcf2b06d2b7ef6d86bd78066c6c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/366996 Commit-Queue: Natalie Chouinard <chouinard@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/tools/src/cmd/cts/roll/roll.go b/tools/src/cmd/cts/roll/roll.go index 5819c1d..5a98cd3 100644 --- a/tools/src/cmd/cts/roll/roll.go +++ b/tools/src/cmd/cts/roll/roll.go
@@ -411,7 +411,7 @@ log.Printf("abandoning %v existing roll...", len(existingRolls)) if !r.flags.dryRun { for _, change := range existingRolls { - if err := r.gerrit.Abandon(ctx, change.ChangeID); err != nil { + if err := r.gerrit.Abandon(ctx, change.ChangeID, ""); err != nil { return err } } @@ -533,7 +533,9 @@ if attempt >= r.flags.maxAttempts { err := fmt.Errorf("CTS failed after %v retries.\nGiving up", attempt) - r.gerrit.Comment(ctx, ps, err.Error(), nil) + if abandonErr := r.gerrit.Abandon(ctx, changeID, err.Error()); abandonErr != nil { + return fmt.Errorf("%w\nfailed to abandon change '%v': %v", err, changeID, abandonErr) + } return err }
diff --git a/tools/src/gerrit/gerrit.go b/tools/src/gerrit/gerrit.go index 835c4c6..4a344f0 100644 --- a/tools/src/gerrit/gerrit.go +++ b/tools/src/gerrit/gerrit.go
@@ -192,9 +192,11 @@ return nil } -// Abandon abandons the change with the given changeID. -func (g *Gerrit) Abandon(ctx context.Context, changeID string) error { - _, _, err := g.client.Changes.AbandonChange(ctx, changeID, &gerrit.AbandonInput{}) +// Abandon abandons the change with the given changeID and optional message. +func (g *Gerrit) Abandon(ctx context.Context, changeID, message string) error { + _, _, err := g.client.Changes.AbandonChange(ctx, changeID, &gerrit.AbandonInput{ + Message: message, + }) if err != nil { return err }