cmd/coordinator: don't delete gomote-created VMs in 45 minutes

remote.go has its own timeout tracking. Don't have the GCE VM cleanup
loop also cleaning them up based on VM's "delete-in" metadata.

The GCE VM cleanup loop will still delete unknown VMs if the
coordinator is restarted.

Change-Id: I5803f3c9431d05df8a31758820e082f60a4878fc
Reviewed-on: https://go-review.googlesource.com/12156
Reviewed-by: Austin Clements <austin@google.com>
diff --git a/cmd/coordinator/gce.go b/cmd/coordinator/gce.go
index 5b18998..f1b211c 100644
--- a/cmd/coordinator/gce.go
+++ b/cmd/coordinator/gce.go
@@ -208,6 +208,14 @@
 		return nil, err
 	}
 
+	deleteIn := vmDeleteTimeout
+	if strings.HasPrefix(rev, "user-") {
+		// Created by gomote (see remote.go), so don't kill it in 45 minutes.
+		// remote.go handles timeouts itself.
+		deleteIn = 0
+		rev = strings.TrimPrefix(rev, "user-")
+	}
+
 	// name is the project-wide unique name of the GCE instance. It can't be longer
 	// than 61 bytes.
 	revPrefix := rev
@@ -225,7 +233,7 @@
 		ProjectID:   projectID,
 		Zone:        projectZone,
 		Description: fmt.Sprintf("Go Builder for %s at %s", typ, rev),
-		DeleteIn:    vmDeleteTimeout,
+		DeleteIn:    deleteIn,
 		OnInstanceRequested: func() {
 			el.logEventTime("instance_create_requested", instName)
 			log.Printf("GCE VM %q now booting", instName)
@@ -462,10 +470,8 @@
 			}
 		}
 		// Delete buildlets (things we made) from previous
-		// generations.  Thenaming restriction (buildlet-*)
-		// prevents us from deleting buildlet VMs used by
-		// Gophers for interactive development & debugging
-		// (non-builder users); those are named "mote-*".
+		// generations. Only deleting things starting with "buildlet-"
+		// is a historical restriction, but still fine for paranoia.
 		if sawDeleteAt && strings.HasPrefix(inst.Name, "buildlet-") && !p.instanceUsed(inst.Name) {
 			if _, ok := deletedVMCache.Get(inst.Name); !ok {
 				log.Printf("Deleting VM %q in zone %q from an earlier coordinator generation ...", inst.Name, zone)
diff --git a/cmd/coordinator/remote.go b/cmd/coordinator/remote.go
index 4dcf3e7..bf6b1f5 100644
--- a/cmd/coordinator/remote.go
+++ b/cmd/coordinator/remote.go
@@ -105,7 +105,7 @@
 
 	// rev is just a comment basically. The GCE pool uses it for
 	// naming.
-	rev := strings.TrimPrefix(user, "user-")
+	rev := user // includes "user-" prefix.
 
 	var closeNotify <-chan bool
 	if cn, ok := w.(http.CloseNotifier); ok {