Skip to content

Commit

Permalink
cmd/coordinator,cmd/retrybuilds: add wipe API to coordinator
Browse files Browse the repository at this point in the history
As part of our migration to combine codebases of the Build Dashboard and
the Coordinator, the first step is to start calling a Coordinator API
for wiping release status of failed builds. This adds a gRPC API to the
coordinator, listening on the same port as the HTTPS listeners.

The Coordinator API in this implementation simply validates and forwards
a request to the dashboard API.

This change also updates cmd/retrybuilds to optionally use the
Coordinator gRPC API for wiping.

Tested locally using the live Dashboard API.

Updates golang/go#34744

Change-Id: I4b34b064625193eb11a280565d701605064a8443
Reviewed-on: https://go-review.googlesource.com/c/build/+/219120
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
  • Loading branch information
toothrot committed Feb 20, 2020
1 parent 3693b7b commit b077d0c
Show file tree
Hide file tree
Showing 10 changed files with 687 additions and 17 deletions.
14 changes: 11 additions & 3 deletions cmd/coordinator/coordinator.go
Expand Up @@ -45,7 +45,9 @@ import (
"unicode"

"go4.org/syncutil"
grpc "grpc.go4.org"
"golang.org/x/build/cmd/coordinator/protos"
"google.golang.org/grpc"
grpc4 "grpc.go4.org"

"cloud.google.com/go/errorreporting"
"cloud.google.com/go/storage"
Expand Down Expand Up @@ -162,8 +164,9 @@ func listenAndServeTLS() {
}

func serveTLS(ln net.Listener) {
// Support HTTP/2 for gRPC handlers.
config := &tls.Config{
NextProtos: []string{"http/1.1"},
NextProtos: []string{"http/1.1", "h2"},
}

if autocertManager != nil {
Expand Down Expand Up @@ -240,6 +243,9 @@ func (fn loggerFunc) CreateSpan(event string, optText ...string) spanlog.Span {
// autocertManager is non-nil if LetsEncrypt is in use.
var autocertManager *autocert.Manager

// grpcServer is a shared gRPC server. It is global, as it needs to be used in places that aren't factored otherwise.
var grpcServer = grpc.NewServer()

func main() {
flag.Parse()

Expand Down Expand Up @@ -293,12 +299,14 @@ func main() {

addHealthCheckers(context.Background())

cc, err := grpc.NewClient(http.DefaultClient, "https://maintner.golang.org")
cc, err := grpc4.NewClient(http.DefaultClient, "https://maintner.golang.org")
if err != nil {
log.Fatal(err)
}
maintnerClient = apipb.NewMaintnerServiceClient(cc)

gs := &gRPCServer{dashboardURL: "https://build.golang.org"}
protos.RegisterCoordinatorServer(grpcServer, gs)
http.HandleFunc("/", handleStatus)
http.HandleFunc("/debug/goroutines", handleDebugGoroutines)
http.HandleFunc("/debug/watcher/", handleDebugWatcher)
Expand Down
209 changes: 209 additions & 0 deletions cmd/coordinator/protos/coordinator.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions cmd/coordinator/protos/coordinator.proto
@@ -0,0 +1,22 @@
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

syntax = "proto3";

package protos;

service Coordinator {
// ClearResults clears build failures from the coordinator to force them to rebuild.
rpc ClearResults(ClearResultsRequest) returns (ClearResultsResponse) {}
}

// ClearResultsRequest specifies the data needed to clear a result.
message ClearResultsRequest {
// builder is the builder to clear results.
string builder = 1;
// hash is the commit hash to clear results.
string hash = 2;
}

message ClearResultsResponse {}
11 changes: 11 additions & 0 deletions cmd/coordinator/protos/protos.go
@@ -0,0 +1,11 @@
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package protos

// Run "go generate" in this directory to update. You need to have:
//
// - a protoc binary (see https://github.com/golang/protobuf#installation)
// - go get -u github.com/golang/protobuf/protoc-gen-go

//go:generate protoc --proto_path=$GOPATH/src:. --go_out=plugins=grpc:. coordinator.proto

0 comments on commit b077d0c

Please sign in to comment.