internal/coordinator: start VMs without external IPs

Resubmission of https://golang.org/cl/354642 now that we have our NAT
config sorted. Hopefully.

We're hitting our external IP quota. Now that we have Cloud NAT set up,
we don't need the external IPs at all. Disable them and stop checking
for them.

Change-Id: I5091ebacd79eb0bddec394f35eb9c7368a699ac4
Reviewed-on: https://go-review.googlesource.com/c/build/+/354756
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
diff --git a/buildlet/gce.go b/buildlet/gce.go
index ea10887..c508a57 100644
--- a/buildlet/gce.go
+++ b/buildlet/gce.go
@@ -71,19 +71,6 @@
 		diskType = "" // a spinning disk
 	}
 
-	// Request an IP address if this is a world-facing buildlet.
-	var accessConfigs []*compute.AccessConfig
-	// TODO(bradfitz): remove the "true ||" part once we figure out why the buildlet
-	// never boots without an IP address. Userspace seems to hang before we get to the buildlet?
-	if true || !opts.TLS.IsZero() {
-		accessConfigs = []*compute.AccessConfig{
-			&compute.AccessConfig{
-				Type: "ONE_TO_ONE_NAT",
-				Name: "External NAT",
-			},
-		}
-	}
-
 	srcImage := "https://www.googleapis.com/compute/v1/projects/" + projectID + "/global/images/" + hconf.VMImage
 	minCPU := hconf.MinCPUPlatform
 	if hconf.IsContainer() {
@@ -126,12 +113,9 @@
 			Items: []string{"https-server"},
 		},
 		Metadata: &compute.Metadata{},
-		NetworkInterfaces: []*compute.NetworkInterface{
-			&compute.NetworkInterface{
-				AccessConfigs: accessConfigs,
-				Network:       prefix + "/global/networks/default-vpc",
-			},
-		},
+		NetworkInterfaces: []*compute.NetworkInterface{{
+			Network: prefix + "/global/networks/default-vpc",
+		}},
 
 		// Prior to git rev 1b1e086fd, we used preemptible
 		// instances, as we were helping test the feature. It was
diff --git a/internal/coordinator/pool/gce.go b/internal/coordinator/pool/gce.go
index 9f70505..d4a40e5 100644
--- a/internal/coordinator/pool/gce.go
+++ b/internal/coordinator/pool/gce.go
@@ -321,11 +321,6 @@
 
 var _ Buildlet = (*GCEBuildlet)(nil)
 
-// maxInstances is a temporary hack because we can't get buildlets to boot
-// without IPs, and we only have 200 IP addresses.
-// TODO(bradfitz): remove this once fixed.
-const maxInstances = 190
-
 // GCEBuildlet manages a pool of GCE buildlets.
 type GCEBuildlet struct {
 	mu sync.Mutex // guards all following
@@ -337,7 +332,6 @@
 	instLeft  int // dead-reckoning instances remain
 	instUsage int
 	cpuUsage  int
-	addrUsage int
 	inst      map[string]time.Time // GCE VM instance name -> creationTime
 }
 
@@ -365,8 +359,6 @@
 		case "INSTANCES":
 			p.instLeft = int(quota.Limit) - int(quota.Usage)
 			p.instUsage = int(quota.Usage)
-		case "IN_USE_ADDRESSES":
-			p.addrUsage = int(quota.Usage)
 		}
 	}
 }
@@ -519,7 +511,7 @@
 //
 // precondition: p.mu must be held.
 func (p *GCEBuildlet) haveQuotaLocked(numCPU int) bool {
-	return p.cpuLeft >= numCPU && p.instLeft >= 1 && len(p.inst) < maxInstances && p.addrUsage < maxInstances
+	return p.cpuLeft >= numCPU && p.instLeft >= 1
 }
 
 func (p *GCEBuildlet) tryAllocateQuota(numCPU int) bool {
@@ -532,7 +524,6 @@
 		p.cpuUsage += numCPU
 		p.cpuLeft -= numCPU
 		p.instLeft--
-		p.addrUsage++
 		return true
 	}
 	return false