cmd/gopherbot: temporarily disable assigning reviewers

This is potentially caught in an infinite loop, which updates
a Gerrit change too many times, leaving the change in an unusable
state.

Also adds a map of deleted issues to prevent an error loop caused
by attempting to post changes to issues that don’t exist.

Updates golang/go#40147
Updates golang/go#40468

Change-Id: I3922d63c146591809324861d40437f43e115748c
Reviewed-on: https://go-review.googlesource.com/c/build/+/247195
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
diff --git a/cmd/gopherbot/gopherbot.go b/cmd/gopherbot/gopherbot.go
index e877781..608bb3b 100644
--- a/cmd/gopherbot/gopherbot.go
+++ b/cmd/gopherbot/gopherbot.go
@@ -228,6 +228,20 @@
 			{"scratch", 72110}: true,
 			{"scratch", 72131}: true,
 		},
+		deletedIssues: map[int32]bool{
+			23772: true,
+			27223: true,
+			28522: true,
+			29309: true,
+			32047: true,
+			32048: true,
+			32469: true,
+			32706: true,
+			32737: true,
+			33315: true,
+			33316: true,
+			39453: true,
+		},
 	}
 	bot.initCorpus()
 
@@ -279,9 +293,10 @@
 
 	knownContributors map[string]bool
 
-	// Until golang.org/issue/22635 is fixed, keep a map of changes that were deleted
-	// to prevent calls to Gerrit that will always 404.
+	// Until golang.org/issue/22635 is fixed, keep a map of changes and issues
+	// that were deleted to prevent calls to Gerrit or GitHub that will always 404.
 	deletedChanges map[gerritChange]bool
+	deletedIssues  map[int32]bool // issue number -> deleted
 
 	releases struct {
 		sync.Mutex
@@ -318,7 +333,10 @@
 
 	// Gerrit tasks are applied to all projects by default.
 	{"abandon scratch reviews", (*gopherbot).abandonScratchReviews},
-	{"assign reviewers to CLs", (*gopherbot).assignReviewersToCLs},
+
+	// Disabled temporarily due to https://golang.org/issue/40147
+	//	{"assign reviewers to CLs", (*gopherbot).assignReviewersToCLs},
+
 	{"access", (*gopherbot).whoNeedsAccess},
 	{"cl2issue", (*gopherbot).cl2issue},
 	{"congratulate new contributors", (*gopherbot).congratulateNewContributors},
@@ -744,7 +762,7 @@
 			return nil
 		}
 		return repo.ForeachIssue(func(gi *maintner.GitHubIssue) error {
-			if gi.NotExist || !gi.Closed || gi.PullRequest || gi.Locked {
+			if gi.NotExist || !gi.Closed || gi.PullRequest || gi.Locked || b.deletedIssues[gi.Number] {
 				return nil
 			}
 			if gi.Updated.After(tooOld) {
@@ -960,7 +978,7 @@
 			return nil
 		}
 		return repo.ForeachIssue(func(gi *maintner.GitHubIssue) error {
-			if gi.Closed || gi.PullRequest || !gi.HasLabel("WaitingForInfo") {
+			if gi.Closed || gi.PullRequest || !gi.HasLabel("WaitingForInfo") || gi.NotExist || b.deletedIssues[gi.Number] {
 				return nil
 			}
 			var waitStart time.Time