dashboard/coordinator: notify dashboard when we're building
Fixes golang/go#9494 Change-Id: Ib9451d41b2dd02d30d2efddbc0ec410a34bdb42c Reviewed-on: https://go-review.googlesource.com/2583 Reviewed-by: Andrew Gerrand <adg@golang.org>
This commit is contained in:
parent
5f779d76c1
commit
e083199384
|
@ -80,6 +80,7 @@ var (
|
|||
projectID string
|
||||
projectZone string
|
||||
computeService *compute.Service
|
||||
externalIP string
|
||||
)
|
||||
|
||||
func initGCE() error {
|
||||
|
@ -101,6 +102,10 @@ func initGCE() error {
|
|||
return errors.New("The coordinator is not running with access to read and write Compute resources. VM support disabled.")
|
||||
|
||||
}
|
||||
externalIP, err = metadata.ExternalIP()
|
||||
if err != nil {
|
||||
return fmt.Errorf("ExternalIP: %v", err)
|
||||
}
|
||||
ts := google.ComputeTokenSource("default")
|
||||
computeService, _ = compute.New(oauth2.NewClient(oauth2.NoContext, ts))
|
||||
return nil
|
||||
|
@ -163,6 +168,29 @@ func (b *buildConfig) recordResult(ok bool, hash, buildLog string, runTime time.
|
|||
return dash("POST", "result", args, req, nil)
|
||||
}
|
||||
|
||||
// pingDashboard is a goroutine that periodically POSTS to build.golang.org/building
|
||||
// to let it know that we're still working on a build.
|
||||
func pingDashboard(st *buildStatus) {
|
||||
u := "https://build.golang.org/building?" + url.Values{
|
||||
"builder": []string{st.name},
|
||||
"key": []string{builderKey(st.name)},
|
||||
"hash": []string{st.rev},
|
||||
"url": []string{fmt.Sprintf("http://%v/logs?name=%s&rev=%s&st=%p", externalIP, st.name, st.rev, st)},
|
||||
}.Encode()
|
||||
for {
|
||||
st.mu.Lock()
|
||||
done := st.done
|
||||
st.mu.Unlock()
|
||||
if !done.IsZero() {
|
||||
return
|
||||
}
|
||||
if res, _ := http.PostForm(u, nil); res != nil {
|
||||
res.Body.Close()
|
||||
}
|
||||
time.Sleep(60 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
type watchConfig struct {
|
||||
repo string // "https://go.googlesource.com/go"
|
||||
dash string // "https://build.golang.org/" (must end in /)
|
||||
|
@ -290,6 +318,7 @@ func main() {
|
|||
conf := builders[work.name]
|
||||
if st, err := startBuilding(conf, work.rev); err == nil {
|
||||
setStatus(work, st)
|
||||
go pingDashboard(st)
|
||||
} else {
|
||||
log.Printf("Error starting to build %v: %v", work, err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue