all: migrate from n1 to e2 instances

We should have similar performance for these machines, and increased
memory availability in some areas.

This is also compliant with an internal policy change.

Change-Id: I07a452a07431322d6fdd4edbb98c5914045d34ed
Reviewed-on: https://go-review.googlesource.com/c/build/+/354757
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
diff --git a/buildlet/ec2_test.go b/buildlet/ec2_test.go
index 91137ea..21897da 100644
--- a/buildlet/ec2_test.go
+++ b/buildlet/ec2_test.go
@@ -363,7 +363,7 @@
 			vmName:            "base_vm",
 			hostType:          "host-foo-bar",
 			opts:              &VMOpts{},
-			wantInstanceType:  "n1-highcpu-2",
+			wantInstanceType:  "e2-highcpu-2",
 			wantName:          "base_vm",
 			wantBuildletName:  "base_vm",
 			wantBuildletImage: "gcr.io/symbolic-datum-552/gobuilder-arm64-aws",
@@ -390,7 +390,7 @@
 			},
 			wantDesc:          "test description",
 			wantImageID:       "awesome_image",
-			wantInstanceType:  "n1-highcpu-2",
+			wantInstanceType:  "e2-highcpu-2",
 			wantName:          "base-vm",
 			wantZone:          "sa-west",
 			wantBuildletName:  "base-vm",
diff --git a/dashboard/builders.go b/dashboard/builders.go
index 78b62a7..2836ede 100644
--- a/dashboard/builders.go
+++ b/dashboard/builders.go
@@ -133,15 +133,15 @@
 	"host-linux-stretch": &HostConfig{
 		Notes:           "Debian Stretch",
 		ContainerImage:  "linux-x86-stretch:latest",
-		machineType:     "n1-standard-4", // 4 vCPUs, 15 GB mem
+		machineType:     "e2-standard-4", // 4 vCPUs, 16 GB mem
 		buildletURLTmpl: "http://storage.googleapis.com/$BUCKET/buildlet.linux-amd64",
 		env:             []string{"GOROOT_BOOTSTRAP=/go1.4"},
 		SSHUsername:     "root",
 	},
 	"host-linux-stretch-morecpu": &HostConfig{
-		Notes:           "Debian Stretch, but on n1-highcpu-16",
+		Notes:           "Debian Stretch, but on e2-highcpu-16",
 		ContainerImage:  "linux-x86-stretch:latest",
-		machineType:     "n1-highcpu-16", // 16 vCPUs, 14.4 GB mem
+		machineType:     "e2-highcpu-16", // 16 vCPUs, 16 GB mem
 		buildletURLTmpl: "http://storage.googleapis.com/$BUCKET/buildlet.linux-amd64",
 		env:             []string{"GOROOT_BOOTSTRAP=/go1.4"},
 		SSHUsername:     "root",
@@ -237,7 +237,7 @@
 	"host-openbsd-amd64-64": &HostConfig{
 		VMImage:            "openbsd-amd64-64-190129a",
 		MinCPUPlatform:     "Intel Skylake", // for better TSC? Maybe? see Issue 29223. builds faster at least.
-		machineType:        "n1-highcpu-4",
+		machineType:        "e2-highcpu-4",
 		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.openbsd-amd64",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/gobootstrap-openbsd-amd64-go1_12.tar.gz",
 		Notes:              "OpenBSD 6.4 with hw.smt=1; GCE VM is built from script in build/env/openbsd-amd64",
@@ -245,7 +245,7 @@
 	},
 	"host-openbsd-386-64": &HostConfig{
 		VMImage:            "openbsd-386-64",
-		machineType:        "n1-highcpu-4",
+		machineType:        "e2-highcpu-4",
 		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.openbsd-386",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/gobootstrap-openbsd-386-go1_12.tar.gz",
 		Notes:              "OpenBSD 6.4; GCE VM is built from script in build/env/openbsd-386",
@@ -253,7 +253,7 @@
 	},
 	"host-openbsd-amd64-68": &HostConfig{
 		VMImage:            "openbsd-amd64-68-v3", // v3 adds 009_exit syspatch; see golang.org/cl/278732.
-		machineType:        "n1-highcpu-4",
+		machineType:        "e2-highcpu-4",
 		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.openbsd-amd64",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/gobootstrap-openbsd-amd64-go1_12.tar.gz",
 		Notes:              "OpenBSD 6.8 (with 009_exit syspatch); GCE VM is built from script in build/env/openbsd-amd64",
@@ -261,7 +261,7 @@
 	},
 	"host-openbsd-386-68": &HostConfig{
 		VMImage:            "openbsd-386-68-v3", // v3 adds 009_exit syspatch; see golang.org/cl/278732.
-		machineType:        "n1-highcpu-4",
+		machineType:        "e2-highcpu-4",
 		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.openbsd-386",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/gobootstrap-openbsd-386-go1_12.tar.gz",
 		Notes:              "OpenBSD 6.8 (with 009_exit syspatch); GCE VM is built from script in build/env/openbsd-386",
@@ -288,7 +288,7 @@
 	"host-freebsd-11_2": &HostConfig{
 		VMImage:            "freebsd-amd64-112",
 		Notes:              "FreeBSD 11.2; GCE VM is built from script in build/env/freebsd-amd64",
-		machineType:        "n1-highcpu-4",
+		machineType:        "e2-highcpu-4",
 		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.freebsd-amd64",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/go1.4-freebsd-amd64.tar.gz",
 		SSHUsername:        "gopher",
@@ -296,7 +296,7 @@
 	"host-freebsd-11_4": &HostConfig{
 		VMImage:            "freebsd-amd64-114",
 		Notes:              "FreeBSD 11.4; GCE VM is built from script in build/env/freebsd-amd64",
-		machineType:        "n1-highcpu-4",
+		machineType:        "e2-highcpu-4",
 		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.freebsd-amd64",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/go1.4-freebsd-amd64.tar.gz",
 		SSHUsername:        "gopher",
@@ -304,15 +304,15 @@
 	"host-freebsd-12_2": &HostConfig{
 		VMImage:            "freebsd-amd64-122",
 		Notes:              "FreeBSD 12.2; GCE VM is built from script in build/env/freebsd-amd64",
-		machineType:        "n1-highcpu-4",
+		machineType:        "e2-highcpu-4",
 		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.freebsd-amd64",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/go1.4-freebsd-amd64.tar.gz",
 		SSHUsername:        "gopher",
 	},
 	"host-freebsd-12_2-big": &HostConfig{
 		VMImage:            "freebsd-amd64-122",
-		Notes:              "Same as host-freebsd-12_2, but on n1-highcpu-16",
-		machineType:        "n1-highcpu-16", // 16 vCPUs, 14.4 GB mem
+		Notes:              "Same as host-freebsd-12_2, but on e2-highcpu-16",
+		machineType:        "e2-highcpu-16", // 16 vCPUs, 16 GB mem
 		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.freebsd-amd64",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/go1.4-freebsd-amd64.tar.gz",
 		SSHUsername:        "gopher",
@@ -320,7 +320,7 @@
 	"host-netbsd-amd64-9_0": &HostConfig{
 		VMImage:            "netbsd-amd64-9-0-2019q4",
 		Notes:              "NetBSD 9.0; GCE VM is built from script in build/env/netbsd-amd64",
-		machineType:        "n1-highcpu-4",
+		machineType:        "e2-highcpu-4",
 		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.netbsd-amd64",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/gobootstrap-netbsd-amd64-2da6b33.tar.gz",
 		SSHUsername:        "root",
@@ -328,7 +328,7 @@
 	"host-netbsd-386-9_0": &HostConfig{
 		VMImage:            "netbsd-i386-9-0-2019q4",
 		Notes:              "NetBSD 9.0; GCE VM is built from script in build/env/netbsd-386",
-		machineType:        "n1-highcpu-4",
+		machineType:        "e2-highcpu-4",
 		buildletURLTmpl:    "https://storage.googleapis.com/$BUCKET/buildlet.netbsd-386",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/gobootstrap-netbsd-386-0b3b511.tar.gz",
 		SSHUsername:        "root",
@@ -390,57 +390,34 @@
 		Notes:              "Plan 9 from 0intro; GCE VM is built from script in build/env/plan9-386",
 		buildletURLTmpl:    "http://storage.googleapis.com/$BUCKET/buildlet.plan9-386",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/gobootstrap-plan9-386.tar.gz",
-
-		// We *were* using n1-standard-1 because Plan 9 can only
-		// reliably use a single CPU. Using 2 or 4 and we see
-		// test failures. See:
-		//    https://golang.org/issue/8393
-		//    https://golang.org/issue/9491
-		// n1-standard-1 has 3.6 GB of memory which WAS (see below)
-		// overkill (userspace probably only sees 2GB anyway),
-		// but it's the cheapest option. And plenty to keep
-		// our ~250 MB of inputs+outputs in its ramfs.
-		//
-		// But the docs says "For the n1 series of machine
-		// types, a virtual CPU is implemented as a single
-		// hyperthread on a 2.6GHz Intel Sandy Bridge Xeon or
-		// Intel Ivy Bridge Xeon (or newer) processor. This
-		// means that the n1-standard-2 machine type will see
-		// a whole physical core."
-		//
-		// ... so we used n1-highcpu-2 (1.80 RAM, still
-		// plenty), just so we can get 1 whole core for the
-		// single-core Plan 9. It will see 2 virtual cores and
-		// only use 1, but we hope that 1 will be more powerful
-		// and we'll stop timing out on tests.
-		machineType: "n1-highcpu-4",
-		env:         []string{"GO_TEST_TIMEOUT_SCALE=3"},
+		machineType:        "e2-highcpu-4",
+		env:                []string{"GO_TEST_TIMEOUT_SCALE=3"},
 	},
 	"host-windows-amd64-2008": &HostConfig{
 		VMImage:            "windows-amd64-server-2008r2-v7",
-		machineType:        "n1-highcpu-4", // 4 vCPUs, 3.6 GB mem
+		machineType:        "e2-highcpu-4", // 4 vCPUs, 4 GB mem
 		buildletURLTmpl:    "http://storage.googleapis.com/$BUCKET/buildlet.windows-amd64",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/go1.4-windows-amd64.tar.gz",
 		SSHUsername:        "gopher",
 	},
 	"host-windows-amd64-2012": &HostConfig{
 		VMImage:            "windows-amd64-server-2012r2-v7",
-		machineType:        "n1-highcpu-4", // 4 vCPUs, 3.6 GB mem
+		machineType:        "e2-highcpu-4", // 4 vCPUs, 4 GB mem
 		buildletURLTmpl:    "http://storage.googleapis.com/$BUCKET/buildlet.windows-amd64",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/go1.4-windows-amd64.tar.gz",
 		SSHUsername:        "gopher",
 	},
 	"host-windows-amd64-2016": &HostConfig{
 		VMImage:            "windows-amd64-server-2016-v7",
-		machineType:        "n1-highcpu-4", // 4 vCPUs, 3.6 GB mem
+		machineType:        "e2-highcpu-4", // 4 vCPUs, 4 GB mem
 		buildletURLTmpl:    "http://storage.googleapis.com/$BUCKET/buildlet.windows-amd64",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/go1.4-windows-amd64.tar.gz",
 		SSHUsername:        "gopher",
 	},
 	"host-windows-amd64-2016-big": &HostConfig{
-		Notes:              "Same as host-windows-amd64-2016, but on n1-highcpu-16",
+		Notes:              "Same as host-windows-amd64-2016, but on e2-highcpu-16",
 		VMImage:            "windows-amd64-server-2016-v7",
-		machineType:        "n1-highcpu-16", // 16 vCPUs, 14.4 GB mem
+		machineType:        "e2-highcpu-16", // 16 vCPUs, 16 GB mem
 		buildletURLTmpl:    "http://storage.googleapis.com/$BUCKET/buildlet.windows-amd64",
 		goBootstrapURLTmpl: "https://storage.googleapis.com/$BUCKET/go1.4-windows-amd64.tar.gz",
 		SSHUsername:        "gopher",
@@ -1306,9 +1283,9 @@
 		// so their /workdir tmpfs can be larger. The COS
 		// image has no swap, so we want to make sure the
 		// /workdir fits completely in memory.
-		return "n1-standard-4" // 4 vCPUs, 15 GB mem
+		return "e2-standard-4" // 4 vCPUs, 16 GB mem
 	}
-	return "n1-highcpu-2"
+	return "e2-highcpu-2"
 }
 
 // IsEC2 returns true if the machine type is an EC2 arm64 type.
diff --git a/env/windows/build.bash b/env/windows/build.bash
index 373473f..d40afdb 100755
--- a/env/windows/build.bash
+++ b/env/windows/build.bash
@@ -36,7 +36,7 @@
 IMAGE_NAME="${1-${BASE_IMAGE}}"
 INSTANCE_NAME="${BUILDER_PREFIX}-buildlet"
 TEST_INSTANCE_NAME="${BUILDER_PREFIX}-buildlet-test"
-MACHINE_TYPE="n1-standard-4"
+MACHINE_TYPE="e2-standard-4"
 BUILDLET_IMAGE="windows-amd64-${IMAGE_NAME}"
 IMAGE_PROJECT=$IMAGE_PROJECT
 BASE_IMAGE=$BASE_IMAGE
diff --git a/internal/coordinator/pool/ec2_test.go b/internal/coordinator/pool/ec2_test.go
index f8be11f..797efc9 100644
--- a/internal/coordinator/pool/ec2_test.go
+++ b/internal/coordinator/pool/ec2_test.go
@@ -32,7 +32,7 @@
 		// set to default gce type because there is no way to set the machine
 		// type from outside of the buildenv package.
 		{
-			Type: "n1-standard-4",
+			Type: "e2-standard-4",
 			CPU:  4,
 		},
 	})
@@ -78,8 +78,8 @@
 				cpuUsed:  0,
 				entries:  make(map[string]*entry),
 				types: map[string]*cloud.InstanceType{
-					"n1-highcpu-2": {
-						Type: "n1-highcpu-2",
+					"e2-highcpu-2": {
+						Type: "e2-highcpu-2",
 						CPU:  4,
 					},
 				},
@@ -101,8 +101,8 @@
 				cpuUsed:  0,
 				entries:  make(map[string]*entry),
 				types: map[string]*cloud.InstanceType{
-					"n1-highcpu-2": {
-						Type: "n1-highcpu-2",
+					"e2-highcpu-2": {
+						Type: "e2-highcpu-2",
 						CPU:  4,
 					},
 				},
@@ -124,8 +124,8 @@
 				cpuUsed:  0,
 				entries:  make(map[string]*entry),
 				types: map[string]*cloud.InstanceType{
-					"n1-highcpu-2": {
-						Type: "n1-highcpu-2",
+					"e2-highcpu-2": {
+						Type: "e2-highcpu-2",
 						CPU:  4,
 					},
 				},
@@ -176,8 +176,8 @@
 				cpuUsed:  0,
 				entries:  make(map[string]*entry),
 				types: map[string]*cloud.InstanceType{
-					"n1-highcpu-2": {
-						Type: "n1-highcpu-2",
+					"e2-highcpu-2": {
+						Type: "e2-highcpu-2",
 						CPU:  4,
 					},
 				},
@@ -201,8 +201,8 @@
 				cpuUsed:  0,
 				entries:  make(map[string]*entry),
 				types: map[string]*cloud.InstanceType{
-					"n1-highcpu-2": {
-						Type: "n1-highcpu-2",
+					"e2-highcpu-2": {
+						Type: "e2-highcpu-2",
 						CPU:  4,
 					},
 				},
@@ -226,8 +226,8 @@
 				cpuUsed:  0,
 				entries:  make(map[string]*entry),
 				types: map[string]*cloud.InstanceType{
-					"n1-highcpu-2": {
-						Type: "n1-highcpu-2",
+					"e2-highcpu-2": {
+						Type: "e2-highcpu-2",
 						CPU:  4,
 					},
 				},
@@ -251,8 +251,8 @@
 				cpuUsed:  0,
 				entries:  make(map[string]*entry),
 				types: map[string]*cloud.InstanceType{
-					"n1-highcpu-2": {
-						Type: "n1-highcpu-2",
+					"e2-highcpu-2": {
+						Type: "e2-highcpu-2",
 						CPU:  4,
 					},
 				},
diff --git a/vcs-test/rebuild-server.sh b/vcs-test/rebuild-server.sh
index e41a56c..a734f2b 100755
--- a/vcs-test/rebuild-server.sh
+++ b/vcs-test/rebuild-server.sh
@@ -9,7 +9,7 @@
 gcloud compute instances create vcs-test --zone=us-central1-a \
 	--address vcs-test \
 	--image-project debian-cloud --image-family debian-9 \
-	--machine-type n1-standard-1 \
+	--machine-type e2-standard-1 \
 	--service-account=vcs-test@symbolic-datum-552.iam.gserviceaccount.com \
 	--scopes cloud-platform \
 	--tags=allow-ssh,http-server,https-server