1
0
mirror of https://github.com/golang/go synced 2024-11-18 20:34:39 -07:00

dashboard: create notion of a builder version

Don't accept results from old builders once we cut over to the git
dashboard.

Change-Id: I1087b9fa174542ecfc7251c13f4319f51eca17b6
Reviewed-on: https://go-review.googlesource.com/1358
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Andrew Gerrand 2014-12-12 10:54:42 +11:00
parent 6f3c548bba
commit 6735829fe0
3 changed files with 29 additions and 12 deletions

View File

@ -26,8 +26,11 @@ import (
"key" "key"
) )
const commitsPerPage = 30 const (
const watcherVersion = 3 // must match dashboard/watcher/watcher.go's watcherVersion commitsPerPage = 30
watcherVersion = 3 // must match dashboard/watcher/watcher.go
builderVersion = 1 // must match dashboard/builder/http.go
)
// commitHandler retrieves commit data or records a new commit. // commitHandler retrieves commit data or records a new commit.
// //
@ -85,10 +88,9 @@ func commitHandler(r *http.Request) (interface{}, error) {
return nil, errors.New("can only POST commits with master key") return nil, errors.New("can only POST commits with master key")
} }
// For now, the commit watcher doesn't support gccgo, // For now, the commit watcher doesn't support gccgo.
// so only do this check for Go commits. // TODO(adg,cmang): remove this exception when gccgo is supported.
// TODO(adg,cmang): remove this check when gccgo is supported. if dashboardForRequest(r) != gccgoDash {
if dashboardForRequest(r) == goDash {
v, _ := strconv.Atoi(r.FormValue("version")) v, _ := strconv.Atoi(r.FormValue("version"))
if v != watcherVersion { if v != watcherVersion {
return nil, fmt.Errorf("rejecting POST from commit watcher; need version %v", watcherVersion) return nil, fmt.Errorf("rejecting POST from commit watcher; need version %v", watcherVersion)
@ -524,6 +526,15 @@ func resultHandler(r *http.Request) (interface{}, error) {
return nil, errBadMethod(r.Method) return nil, errBadMethod(r.Method)
} }
// For now, the gccgo builders are using the old stuff.
// TODO(adg,cmang): remove this exception when gccgo is updated.
if dashboardForRequest(r) != gccgoDash {
v, _ := strconv.Atoi(r.FormValue("version"))
if v != builderVersion {
return nil, fmt.Errorf("rejecting POST from builder; need version %v", builderVersion)
}
}
c := contextForRequest(r) c := contextForRequest(r)
res := new(Result) res := new(Result)
defer r.Body.Close() defer r.Body.Close()

View File

@ -16,6 +16,8 @@ import (
"time" "time"
) )
const builderVersion = 1 // keep in sync with dashboard/app/build/handler.go
type obj map[string]interface{} type obj map[string]interface{}
// dash runs the given method and command on the dashboard. // dash runs the given method and command on the dashboard.
@ -24,15 +26,19 @@ type obj map[string]interface{}
// If resp is non-nil the server's response is decoded into the value pointed // If resp is non-nil the server's response is decoded into the value pointed
// to by resp (resp must be a pointer). // to by resp (resp must be a pointer).
func dash(meth, cmd string, args url.Values, req, resp interface{}) error { func dash(meth, cmd string, args url.Values, req, resp interface{}) error {
argsCopy := url.Values{"version": {fmt.Sprint(builderVersion)}}
for k, v := range args {
if k == "version" {
panic(`dash: reserved args key: "version"`)
}
argsCopy[k] = v
}
var r *http.Response var r *http.Response
var err error var err error
if *verbose { if *verbose {
log.Println("dash <-", meth, cmd, args, req) log.Println("dash <-", meth, cmd, argsCopy, req)
}
cmd = *dashboard + "/" + cmd
if len(args) > 0 {
cmd += "?" + args.Encode()
} }
cmd = *dashboard + "/" + cmd + "?" + argsCopy.Encode()
switch meth { switch meth {
case "GET": case "GET":
if req != nil { if req != nil {

View File

@ -53,7 +53,7 @@ var (
buildRevision = flag.String("rev", "", "Build specified revision and exit") buildRevision = flag.String("rev", "", "Build specified revision and exit")
buildCmd = flag.String("cmd", filepath.Join(".", allCmd), "Build command (specify relative to go/src/)") buildCmd = flag.String("cmd", filepath.Join(".", allCmd), "Build command (specify relative to go/src/)")
buildTool = flag.String("tool", "go", "Tool to build.") buildTool = flag.String("tool", "go", "Tool to build.")
gcPath = flag.String("gcpath", "code.google.com/p/go", "Path to download gc from") gcPath = flag.String("gcpath", "go.googlesource.com/go", "Path to download gc from")
gccPath = flag.String("gccpath", "https://github.com/mirrors/gcc.git", "Path to download gcc from") gccPath = flag.String("gccpath", "https://github.com/mirrors/gcc.git", "Path to download gcc from")
gccOpts = flag.String("gccopts", "", "Command-line options to pass to `make` when building gccgo") gccOpts = flag.String("gccopts", "", "Command-line options to pass to `make` when building gccgo")
benchPath = flag.String("benchpath", "golang.org/x/benchmarks/bench", "Path to download benchmarks from") benchPath = flag.String("benchpath", "golang.org/x/benchmarks/bench", "Path to download benchmarks from")