Skip to content

Commit

Permalink
cmd/coordinator: stop EC2 buildlet pool
Browse files Browse the repository at this point in the history
All EC2 builders have been migrated to LUCI and stopped in coordinator.
Stop the pool as well. Its permissions have been revoked and it prints
errors continuously. Also drop an unhelpful printf.

For golang/go#67761.

Change-Id: I6ce48e222a2dc88f7d5a7386f8cc9d5b1e8bac71
Reviewed-on: https://go-review.googlesource.com/c/build/+/612559
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
  • Loading branch information
dmitshur authored and gopherbot committed Sep 12, 2024
1 parent dba0128 commit 4ca568d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
14 changes: 10 additions & 4 deletions cmd/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import (
gomoteprotos "golang.org/x/build/internal/gomote/protos"
"golang.org/x/build/internal/https"
"golang.org/x/build/internal/metrics"
"golang.org/x/build/internal/migration"
"golang.org/x/build/internal/secret"
"golang.org/x/build/kubernetes/gke"
"golang.org/x/build/maintner/maintnerd/apipb"
Expand Down Expand Up @@ -285,8 +286,8 @@ func main() {
if *mode == "prod" || (*mode == "dev" && *devEnableEC2) {
// TODO(golang.org/issues/38337) the coordinator will use a package scoped pool
// until the coordinator is refactored to not require them.
ec2Pool := mustCreateEC2BuildletPool(sc, sp.IsSession)
defer ec2Pool.Close()
ec2PoolClose := mustCreateEC2BuildletPool(sc, sp.IsSession)
defer ec2PoolClose()
}

if *mode == "dev" {
Expand Down Expand Up @@ -2248,7 +2249,12 @@ func mustCreateSecretClientOnGCE() *secret.Client {
return secret.MustNewClient()
}

func mustCreateEC2BuildletPool(sc *secret.Client, isRemoteBuildlet func(instName string) bool) *pool.EC2Buildlet {
func mustCreateEC2BuildletPool(sc *secret.Client, isRemoteBuildlet func(instName string) bool) (close func()) {
if migration.StopEC2BuildletPool {
log.Println("not creating EC2 buildlet pool")
return func() {}
}

awsKeyID, err := sc.Retrieve(context.Background(), secret.NameAWSKeyID)
if err != nil {
log.Fatalf("unable to retrieve secret %q: %s", secret.NameAWSKeyID, err)
Expand All @@ -2268,7 +2274,7 @@ func mustCreateEC2BuildletPool(sc *secret.Client, isRemoteBuildlet func(instName
if err != nil {
log.Fatalf("unable to create EC2 buildlet pool: %s", err)
}
return ec2Pool
return ec2Pool.Close
}

func mustRetrieveSSHCertificateAuthority() (privateKey []byte) {
Expand Down
2 changes: 0 additions & 2 deletions cmd/coordinator/internal/legacydash/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"html/template"
"log"
"net/http"
"os"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -1176,7 +1175,6 @@ func shortUser(user string) string {
}

func httpStatusOfErr(err error) int {
fmt.Fprintf(os.Stderr, "Got error: %#v, code %v\n", err, grpc.Code(err))
switch grpc.Code(err) {
case codes.NotFound:
return http.StatusNotFound
Expand Down
1 change: 1 addition & 0 deletions internal/migration/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package migration
const (
StopLegacyMiscCompileTryBots = true
StopInternalModuleProxy = true
StopEC2BuildletPool = true

// StopPortedBuilder controls whether ported builders should be stopped,
// instead of just made invisible in the web UI.
Expand Down

0 comments on commit 4ca568d

Please sign in to comment.