Skip to content

Commit 5d3521b

Browse files
thepuddsgopherbot
authored andcommitted
cmd/gerritbot: avoid changing the content of comment sync messages
CL 525976 included an update of several messages to use go.dev/wiki shortlinks instead of the equivalent github.com/golang/go/wiki links, including to be more future-proof given the wiki content is likely to move in the near future. This included updating the URL used in the sync messages posted on the GitHub PR to notify a contributor of a new Gerrit comment. This in turn caused GerritBot to start re-posting what were effectively duplicate sync comments to various open GitHub PRs. This is because GerritBot's sync of Gerrit comments to the GitHub PR is nicely simple, and currently relies on historical sync messages on the PR exactly matching what the current incarnation of GerritBot would have posted for old Gerrit comments. If the sync message content changes, GerritBot thinks it has never posted about even old Gerrit comments because it cannot find an exact match on the PR, and hence posts the new sync message content about old Gerrit comments. This CL restores the content of the sync messages, and adds a comment to help future contributors. The other messages modified in CL 525976 were not affected in the same way because they are posted in reaction to an event of creating a new GitHub PR or an update to the PR. Those other messages have also recently been modified by other CLs without triggering reposts. CL 525976 was noticed as misbehaving within ~10 minutes of being deployed. Also within ~10 minutes of being deployed, GerritBot encountered a 403 error and stopped posting duplicates: 403 You have exceeded a secondary rate limit and have been temporarily blocked from content creation The deployment was rolled back ~10 minutes after that. Updates golang/go#61573 Change-Id: Ibc5d299494baaa26118916799eaed023e5ccb26c Reviewed-on: https://go-review.googlesource.com/c/build/+/530736 Reviewed-by: Heschi Kreinick <[email protected]> Auto-Submit: Heschi Kreinick <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 795af09 commit 5d3521b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cmd/gerritbot/gerritbot.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,13 +510,22 @@ func (b *bot) syncGerritCommentsToGitHub(ctx context.Context, pr *github.PullReq
510510
if err != nil {
511511
return fmt.Errorf("b.gerritMessageAuthorName: %v", err)
512512
}
513+
514+
// NOTE: care is required to update this message. GerritBot's sync of Gerrit comments
515+
// to the GitHub PR is simple and currently relies on historical sync messages on the
516+
// PR exactly matching what the current incarnation of GerritBot would have posted for
517+
// old Gerrit comments. As implemented, changing the content here will cause
518+
// GerritBot to post effectively duplicate messages to the GitHub PR. See CL 530736 for details.
519+
// TODO: allow message content to evolve more easily, perhaps by writing an ID or timestamp
520+
// for the Gerrit message being synced, or a coarser solution like having a time cutoff,
521+
// or tracking more state, or some other solution.
513522
header := fmt.Sprintf("Message from %s:\n", authorName)
514523
msg := fmt.Sprintf(`
515524
%s
516525
517526
---
518527
Please don’t reply on this GitHub thread. Visit [golang.org/cl/%d](https://go-review.googlesource.com/c/%s/+/%d#message-%s).
519-
After addressing review feedback, remember to [publish your drafts](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it)!`,
528+
After addressing review feedback, remember to [publish your drafts](https://github.com/golang/go/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it)!`,
520529
m.Message, cl.Number, cl.Project.Project(), cl.Number, m.Meta.Hash.String())
521530
if err := b.postGitHubMessageNoDup(ctx, repo.GetOwner().GetLogin(), repo.GetName(), pr.GetNumber(), header, msg); err != nil {
522531
return fmt.Errorf("postGitHubMessageNoDup: %v", err)

0 commit comments

Comments
 (0)