From 4ca568d461616f66f6d6c40c5391e835483074a0 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Thu, 12 Sep 2024 09:40:39 -0400 Subject: [PATCH] cmd/coordinator: stop EC2 buildlet pool 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 Reviewed-by: Tim King Reviewed-by: Dmitri Shuralyov Auto-Submit: Dmitri Shuralyov --- cmd/coordinator/coordinator.go | 14 ++++++++++---- cmd/coordinator/internal/legacydash/ui.go | 2 -- internal/migration/migration.go | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cmd/coordinator/coordinator.go b/cmd/coordinator/coordinator.go index c0b79df2f2..5a410500ef 100644 --- a/cmd/coordinator/coordinator.go +++ b/cmd/coordinator/coordinator.go @@ -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" @@ -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" { @@ -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) @@ -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) { diff --git a/cmd/coordinator/internal/legacydash/ui.go b/cmd/coordinator/internal/legacydash/ui.go index f533f6d285..5634c82eb8 100644 --- a/cmd/coordinator/internal/legacydash/ui.go +++ b/cmd/coordinator/internal/legacydash/ui.go @@ -16,7 +16,6 @@ import ( "html/template" "log" "net/http" - "os" "sort" "strconv" "strings" @@ -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 diff --git a/internal/migration/migration.go b/internal/migration/migration.go index 5adfe01bce..0fc34d3792 100644 --- a/internal/migration/migration.go +++ b/internal/migration/migration.go @@ -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.