cmd/coordinator: drop bookkeeping for old revdial v1 buildlets

By now there are no reverse builders that still use revdial v1,
all are version 23 or newer (where revdial v2 support is added).

Most of the code was dropped in 2019 (in CL 208598),
this CL deletes some remaining obsolete bookkeeping.

Updates golang/go#31639.

Change-Id: Icedd48f9342ea88287c5d580f085785c57846a65
Reviewed-on: https://go-review.googlesource.com/c/build/+/406214
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
diff --git a/buildlet/buildletclient.go b/buildlet/buildletclient.go
index 248d4f9..2ca30d4 100644
--- a/buildlet/buildletclient.go
+++ b/buildlet/buildletclient.go
@@ -677,7 +677,7 @@
 // A coordinator can use the provided information to decide what, if anything,
 // to do with a buildlet.
 type Status struct {
-	Version int // buildlet version, coordinator rejects any value less than 1.
+	Version int // buildlet version, coordinator rejects value that is too old (see minBuildletVersion).
 }
 
 // Status returns an Status value describing this buildlet.
diff --git a/internal/coordinator/pool/reverse.go b/internal/coordinator/pool/reverse.go
index 1602696..87ec49e 100644
--- a/internal/coordinator/pool/reverse.go
+++ b/internal/coordinator/pool/reverse.go
@@ -53,19 +53,16 @@
 	"golang.org/x/build/types"
 )
 
-const minBuildletVersion = 1
+const minBuildletVersion = 23
 
 var (
 	reversePool = &ReverseBuildletPool{
-		oldInUse:     make(map[buildlet.Client]bool),
 		hostLastGood: make(map[string]time.Time),
 	}
 
 	builderMasterKey []byte
 )
 
-const maxOldRevdialUsers = 10
-
 // SetBuilderMasterKey sets the builder master key used
 // to generate keys used by the builders.
 func SetBuilderMasterKey(masterKey []byte) {
@@ -91,11 +88,6 @@
 
 	waiters map[string]int // hostType => number waiters blocked in GetBuildlet
 
-	// oldInUse tracks which buildlets with the old revdial code are currently in use.
-	// These are a liability due to runaway memory issues (Issue 31639) so
-	// we bound how many can be running at once. Fortunately there aren't many left.
-	oldInUse map[buildlet.Client]bool
-
 	// hostLastGood tracks when buildlets were last seen to be
 	// healthy. It's only used by the health reporting code (in
 	// status.go). The reason it's a map on ReverseBuildletPool
@@ -190,15 +182,9 @@
 			busy++
 			continue
 		}
-		if b.isOldRevDial && len(p.oldInUse) >= maxOldRevdialUsers {
-			continue
-		}
 		// Found an unused match.
 		b.inUse = true
 		b.inUseTime = time.Now()
-		if b.isOldRevDial {
-			p.oldInUse[b.client] = true
-		}
 		return b.client, 0
 	}
 	return nil, busy
@@ -232,7 +218,6 @@
 func (p *ReverseBuildletPool) nukeBuildlet(victim buildlet.Client) {
 	p.mu.Lock()
 	defer p.mu.Unlock()
-	delete(p.oldInUse, victim)
 	for i, rb := range p.buildlets {
 		if rb.client == victim {
 			defer rb.conn.Close()
@@ -406,7 +391,6 @@
 			inUse[b.hostType]++
 		}
 	}
-	numOldInUse := len(p.oldInUse)
 	numConnected := len(buildlets)
 	p.mu.Unlock()
 
@@ -419,7 +403,6 @@
 	io.WriteString(w, "<b>Reverse pool stats</b><ul>\n")
 	fmt.Fprintf(w, "<li>Buildlets connected: %d</li>\n", numConnected)
 	fmt.Fprintf(w, "<li>Buildlets in use: %d</li>\n", numInUse)
-	fmt.Fprintf(w, "<li>Old revdial buildlets in use: %d</li>\n", numOldInUse)
 	io.WriteString(w, "</ul>")
 
 	io.WriteString(w, "<b>Reverse pool by host type</b> (in use / total)<ul>\n")
@@ -528,8 +511,7 @@
 	// It doesn't have to be a complete DNS name.
 	hostname string
 	// version is the reverse buildlet's version.
-	version      string
-	isOldRevDial bool // version 22 or under: using the v1 revdial package (Issue 31639)
+	version string
 
 	// sessRand is the unique random number for every unique buildlet session.
 	sessRand string
@@ -654,7 +636,7 @@
 		return
 	}
 	if status.Version < minBuildletVersion {
-		log.Printf("Buildlet too old: %s, %+v", r.RemoteAddr, status)
+		log.Printf("Buildlet too old (need version %d or newer): %s, %+v", minBuildletVersion, r.RemoteAddr, status)
 		conn.Close()
 		return
 	}
@@ -662,14 +644,13 @@
 
 	now := time.Now()
 	b := &reverseBuildlet{
-		hostname:     hostname,
-		version:      buildletVersion,
-		isOldRevDial: status.Version < 23,
-		hostType:     hostType,
-		client:       client,
-		conn:         conn,
-		inUseTime:    now,
-		regTime:      now,
+		hostname:  hostname,
+		version:   buildletVersion,
+		hostType:  hostType,
+		client:    client,
+		conn:      conn,
+		inUseTime: now,
+		regTime:   now,
 	}
 	reversePool.addBuildlet(b)
 }