Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: status/go/status/main.go

Issue 1171823005: Add autoroll package, alerts for failed rolls, recent rolls on Status (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: tweaks Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 Provides roll-up statuses for Skia build/test/perf. 2 Provides roll-up statuses for Skia build/test/perf.
3 */ 3 */
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "encoding/json" 8 "encoding/json"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
11 "net/http" 11 "net/http"
12 "path" 12 "path"
13 "path/filepath" 13 "path/filepath"
14 "runtime" 14 "runtime"
15 "strconv" 15 "strconv"
16 "strings" 16 "strings"
17 "text/template" 17 "text/template"
18 "time" 18 "time"
19 "unicode" 19 "unicode"
20 ) 20 )
21 21
22 import ( 22 import (
23 "github.com/gorilla/mux" 23 "github.com/gorilla/mux"
24 "github.com/skia-dev/glog" 24 "github.com/skia-dev/glog"
25 ) 25 )
26 26
27 import ( 27 import (
28 "go.skia.org/infra/go/autoroll"
28 "go.skia.org/infra/go/buildbot" 29 "go.skia.org/infra/go/buildbot"
29 "go.skia.org/infra/go/common" 30 "go.skia.org/infra/go/common"
30 "go.skia.org/infra/go/gitinfo" 31 "go.skia.org/infra/go/gitinfo"
31 "go.skia.org/infra/go/influxdb" 32 "go.skia.org/infra/go/influxdb"
32 "go.skia.org/infra/go/login" 33 "go.skia.org/infra/go/login"
33 "go.skia.org/infra/go/metadata" 34 "go.skia.org/infra/go/metadata"
34 "go.skia.org/infra/go/skiaversion" 35 "go.skia.org/infra/go/skiaversion"
35 "go.skia.org/infra/go/timer" 36 "go.skia.org/infra/go/timer"
36 "go.skia.org/infra/go/util" 37 "go.skia.org/infra/go/util"
37 "go.skia.org/infra/status/go/commit_cache" 38 "go.skia.org/infra/status/go/commit_cache"
(...skipping 11 matching lines...) Expand all
49 commitCaches map[string]*commit_cache.CommitCache = nil 50 commitCaches map[string]*commit_cache.CommitCache = nil
50 buildbotDashTemplate *template.Template = nil 51 buildbotDashTemplate *template.Template = nil
51 commitsTemplate *template.Template = nil 52 commitsTemplate *template.Template = nil
52 hostsTemplate *template.Template = nil 53 hostsTemplate *template.Template = nil
53 infraTemplate *template.Template = nil 54 infraTemplate *template.Template = nil
54 dbClient *influxdb.Client = nil 55 dbClient *influxdb.Client = nil
55 goldGMStatus *util.IntPollingStatus = nil 56 goldGMStatus *util.IntPollingStatus = nil
56 goldSKPStatus *util.IntPollingStatus = nil 57 goldSKPStatus *util.IntPollingStatus = nil
57 goldImageStatus *util.IntPollingStatus = nil 58 goldImageStatus *util.IntPollingStatus = nil
58 perfStatus *util.PollingStatus = nil 59 perfStatus *util.PollingStatus = nil
60 rollStatus *util.PollingStatus = nil
59 slaveHosts *util.PollingStatus = nil 61 slaveHosts *util.PollingStatus = nil
60 androidDevices *util.PollingStatus = nil 62 androidDevices *util.PollingStatus = nil
61 sshDevices *util.PollingStatus = nil 63 sshDevices *util.PollingStatus = nil
62 ) 64 )
63 65
64 // flags 66 // flags
65 var ( 67 var (
66 graphiteServer = flag.String("graphite_server", "localhost:2003", "Where is Graphite metrics ingestion server running.") 68 graphiteServer = flag.String("graphite_server", "localhost:2003", "Where is Graphite metrics ingestion server running.")
67 host = flag.String("host", "localhost", "HTTP service host") 69 host = flag.String("host", "localhost", "HTTP service host")
68 port = flag.String("port", ":8002", "HTTP service port (e.g., ':8002')") 70 port = flag.String("port", ":8002", "HTTP service port (e.g., ':8002')")
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if err := json.NewEncoder(w).Encode(map[string]interface{}{ 412 if err := json.NewEncoder(w).Encode(map[string]interface{}{
411 "gm": goldGMStatus, 413 "gm": goldGMStatus,
412 "skp": goldSKPStatus, 414 "skp": goldSKPStatus,
413 "image": goldImageStatus, 415 "image": goldImageStatus,
414 }); err != nil { 416 }); err != nil {
415 glog.Errorf("Failed to write or encode output: %s", err) 417 glog.Errorf("Failed to write or encode output: %s", err)
416 return 418 return
417 } 419 }
418 } 420 }
419 421
422 func autoRollJsonHandler(w http.ResponseWriter, r *http.Request) {
423 w.Header().Set("Content-Type", "application/json")
424 if err := json.NewEncoder(w).Encode(rollStatus); err != nil {
425 util.ReportError(w, r, err, fmt.Sprintf("Failed to report AutoRo ll status: %v", err))
426 return
427 }
428 }
429
420 func slaveHostsJsonHandler(w http.ResponseWriter, r *http.Request) { 430 func slaveHostsJsonHandler(w http.ResponseWriter, r *http.Request) {
421 w.Header().Set("Content-Type", "application/json") 431 w.Header().Set("Content-Type", "application/json")
422 if err := json.NewEncoder(w).Encode(map[string]interface{}{ 432 if err := json.NewEncoder(w).Encode(map[string]interface{}{
423 "hosts": slaveHosts, 433 "hosts": slaveHosts,
424 "androidDevices": androidDevices, 434 "androidDevices": androidDevices,
425 "sshDevices": sshDevices, 435 "sshDevices": sshDevices,
426 }); err != nil { 436 }); err != nil {
427 glog.Errorf("Failed to write or encode output: %s", err) 437 glog.Errorf("Failed to write or encode output: %s", err)
428 return 438 return
429 } 439 }
(...skipping 23 matching lines...) Expand all
453 r.HandleFunc("/buildbots", buildbotDashHandler) 463 r.HandleFunc("/buildbots", buildbotDashHandler)
454 r.HandleFunc("/hosts", hostsHandler) 464 r.HandleFunc("/hosts", hostsHandler)
455 r.HandleFunc("/infra", infraHandler) 465 r.HandleFunc("/infra", infraHandler)
456 builders := r.PathPrefix("/json/{repo}/builders/{builder}").Subrouter() 466 builders := r.PathPrefix("/json/{repo}/builders/{builder}").Subrouter()
457 builders.HandleFunc("/status", addBuilderStatusHandler).Methods("POST") 467 builders.HandleFunc("/status", addBuilderStatusHandler).Methods("POST")
458 commits := r.PathPrefix("/json/{repo}/commits").Subrouter() 468 commits := r.PathPrefix("/json/{repo}/commits").Subrouter()
459 commits.HandleFunc("/", commitsJsonHandler) 469 commits.HandleFunc("/", commitsJsonHandler)
460 commits.HandleFunc("/{commit:[a-f0-9]+}/comments", addCommitCommentHandl er).Methods("POST") 470 commits.HandleFunc("/{commit:[a-f0-9]+}/comments", addCommitCommentHandl er).Methods("POST")
461 r.HandleFunc("/json/perfAlerts", perfJsonHandler) 471 r.HandleFunc("/json/perfAlerts", perfJsonHandler)
462 r.HandleFunc("/json/goldStatus", goldJsonHandler) 472 r.HandleFunc("/json/goldStatus", goldJsonHandler)
473 r.HandleFunc("/json/autoRoll", autoRollJsonHandler)
rmistry 2015/06/10 20:20:54 sort the HandleFuncs ?
borenet 2015/06/11 11:40:10 Done.
463 r.HandleFunc("/json/slaveHosts", slaveHostsJsonHandler) 474 r.HandleFunc("/json/slaveHosts", slaveHostsJsonHandler)
464 r.HandleFunc("/json/version", skiaversion.JsonHandler) 475 r.HandleFunc("/json/version", skiaversion.JsonHandler)
465 r.HandleFunc("/oauth2callback/", login.OAuth2CallbackHandler) 476 r.HandleFunc("/oauth2callback/", login.OAuth2CallbackHandler)
466 r.HandleFunc("/logout/", login.LogoutHandler) 477 r.HandleFunc("/logout/", login.LogoutHandler)
467 r.HandleFunc("/loginstatus/", login.StatusHandler) 478 r.HandleFunc("/loginstatus/", login.StatusHandler)
468 http.Handle("/", util.LoggingGzipRequestResponse(r)) 479 http.Handle("/", util.LoggingGzipRequestResponse(r))
469 glog.Infof("Ready to serve on %s", serverURL) 480 glog.Infof("Ready to serve on %s", serverURL)
470 glog.Fatal(http.ListenAndServe(*port, nil)) 481 glog.Fatal(http.ListenAndServe(*port, nil))
471 } 482 }
472 483
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 } 587 }
577 androidDevices, err = device_cfg.AndroidDeviceCfgPoller(*workdir) 588 androidDevices, err = device_cfg.AndroidDeviceCfgPoller(*workdir)
578 if err != nil { 589 if err != nil {
579 glog.Fatal(err) 590 glog.Fatal(err)
580 } 591 }
581 sshDevices, err = device_cfg.SSHDeviceCfgPoller(*workdir) 592 sshDevices, err = device_cfg.SSHDeviceCfgPoller(*workdir)
582 if err != nil { 593 if err != nil {
583 glog.Fatal(err) 594 glog.Fatal(err)
584 } 595 }
585 596
597 // Load AutoRoll data in a loop.
598 rollStatus, err = autoroll.AutoRollStatusPoller()
599 if err != nil {
600 glog.Fatal(err)
601 }
602
586 runServer(serverURL) 603 runServer(serverURL)
587 } 604 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698