Skip to content

Commit

Permalink
cmd/coordinator: disable Kubernetes mode in local "dev" mode
Browse files Browse the repository at this point in the history
Restore the local "dev" mode after the refactor in CL 422956.
The development environment doesn't have KubeServices set to
anything, so KubeServices.Location() was otherwise panicking.

While here, also do fewer things in background of "dev" mode
unless appropriate dev flags are turned on.

For golang/go#65913.

Change-Id: Ib7409c28e39f2dbf98e08a4bcbd21cd45cb81aa1
Reviewed-on: https://go-review.googlesource.com/c/build/+/567496
Reviewed-by: Dmitri Shuralyov <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Michael Knyszek <[email protected]>
Auto-Submit: Dmitri Shuralyov <[email protected]>
  • Loading branch information
dmitshur authored and gopherbot committed Feb 29, 2024
1 parent b305989 commit 9d46ba7
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions cmd/coordinator/coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,20 @@ func main() {

gce := pool.NewGCEConfiguration()

goKubeClient, err := gke.NewClient(context.Background(),
gce.BuildEnv().KubeServices.Name,
gce.BuildEnv().KubeServices.Location(),
gke.OptNamespace(gce.BuildEnv().KubeServices.Namespace),
gke.OptProject(gce.BuildEnv().ProjectName),
gke.OptTokenSource(gce.GCPCredentials().TokenSource))
if err != nil {
log.Fatalf("connecting to GKE failed: %v", err)
if gce.BuildEnv().KubeServices.Name != "" {
goKubeClient, err := gke.NewClient(context.Background(),
gce.BuildEnv().KubeServices.Name,
gce.BuildEnv().KubeServices.Location(),
gke.OptNamespace(gce.BuildEnv().KubeServices.Namespace),
gke.OptProject(gce.BuildEnv().ProjectName),
gke.OptTokenSource(gce.GCPCredentials().TokenSource))
if err != nil {
log.Fatalf("connecting to GKE failed: %v", err)
}
go monitorGitMirror(goKubeClient)
} else {
log.Println("Kubernetes services disabled due to empty KubeServices.Name")
}
go monitorGitMirror(goKubeClient)

if *mode == "prod" || (*mode == "dev" && *devEnableEC2) {
// TODO(golang.org/issues/38337) the coordinator will use a package scoped pool
Expand Down Expand Up @@ -364,7 +368,9 @@ func main() {
if *mode == "dev" {
// TODO(crawshaw): do more in dev mode
gce.BuildletPool().SetEnabled(*devEnableGCE)
go findWorkLoop()
if *devEnableGCE || *devEnableEC2 {
go findWorkLoop()
}
} else {
go gce.BuildletPool().CleanUpOldVMs()

Expand Down

0 comments on commit 9d46ba7

Please sign in to comment.