aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard/app/api.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-11-30 17:14:18 +0100
committerDmitry Vyukov <dvyukov@google.com>2017-12-01 13:58:11 +0100
commit2fa91450df792689c42bd52f98ffdacee99ace91 (patch)
tree6bac47c9c556725b596af31c0212d57fc6157575 /dashboard/app/api.go
parent5683420f11c9eb812a57f2c5786b38015a652fa0 (diff)
dashboard/app: add manager monitoring
Make it possible to monitor health and operation of all managers from dashboard. 1. Notify dashboard about internal syz-ci errors (currently we don't know when/if they happen). 2. Send statistics from managers to dashboard.
Diffstat (limited to 'dashboard/app/api.go')
-rw-r--r--dashboard/app/api.go56
1 files changed, 49 insertions, 7 deletions
diff --git a/dashboard/app/api.go b/dashboard/app/api.go
index db265f8b8..ef1f344fd 100644
--- a/dashboard/app/api.go
+++ b/dashboard/app/api.go
@@ -43,6 +43,7 @@ var apiNamespaceHandlers = map[string]APINamespaceHandler{
"report_crash": apiReportCrash,
"report_failed_repro": apiReportFailedRepro,
"need_repro": apiNeedRepro,
+ "manager_stats": apiManagerStats,
}
type JSONHandler func(c context.Context, r *http.Request) (interface{}, error)
@@ -204,6 +205,12 @@ func apiUploadBuild(c context.Context, ns string, r *http.Request) (interface{},
return nil, err
}
}
+ if err := updateManager(c, ns, req.Manager, func(mgr *Manager, stats *ManagerStats) {
+ mgr.CurrentBuild = req.ID
+ mgr.FailedBuildBug = ""
+ }); err != nil {
+ return nil, err
+ }
return nil, nil
}
@@ -374,7 +381,14 @@ func apiReportBuildError(c context.Context, ns string, r *http.Request) (interfa
if err := uploadBuild(c, ns, &req.Build, BuildFailed); err != nil {
return nil, err
}
- if _, err := reportCrash(c, ns, &req.Crash); err != nil {
+ req.Crash.BuildID = req.Build.ID
+ bug, err := reportCrash(c, ns, &req.Crash)
+ if err != nil {
+ return nil, err
+ }
+ if err := updateManager(c, ns, req.Build.Manager, func(mgr *Manager, stats *ManagerStats) {
+ mgr.FailedBuildBug = bugKeyHash(bug.Namespace, bug.Title, bug.Seq)
+ }); err != nil {
return nil, err
}
return nil, nil
@@ -387,10 +401,17 @@ func apiReportCrash(c context.Context, ns string, r *http.Request) (interface{},
if err := json.NewDecoder(r.Body).Decode(req); err != nil {
return nil, fmt.Errorf("failed to unmarshal request: %v", err)
}
- return reportCrash(c, ns, req)
+ bug, err := reportCrash(c, ns, req)
+ if err != nil {
+ return nil, err
+ }
+ resp := &dashapi.ReportCrashResp{
+ NeedRepro: needRepro(bug),
+ }
+ return resp, nil
}
-func reportCrash(c context.Context, ns string, req *dashapi.Crash) (interface{}, error) {
+func reportCrash(c context.Context, ns string, req *dashapi.Crash) (*Bug, error) {
req.Title = limitLength(req.Title, maxTextLen)
req.Maintainers = email.MergeEmailLists(req.Maintainers)
if req.Corrupted {
@@ -488,10 +509,7 @@ func reportCrash(c context.Context, ns string, req *dashapi.Crash) (interface{},
if saveCrash {
purgeOldCrashes(c, bug, bugKey)
}
- resp := &dashapi.ReportCrashResp{
- NeedRepro: needRepro(bug),
- }
- return resp, nil
+ return bug, nil
}
func purgeOldCrashes(c context.Context, bug *Bug, bugKey *datastore.Key) {
@@ -603,6 +621,30 @@ func apiNeedRepro(c context.Context, ns string, r *http.Request) (interface{}, e
return resp, nil
}
+func apiManagerStats(c context.Context, ns string, r *http.Request) (interface{}, error) {
+ req := new(dashapi.ManagerStatsReq)
+ if err := json.NewDecoder(r.Body).Decode(req); err != nil {
+ return nil, fmt.Errorf("failed to unmarshal request: %v", err)
+ }
+ now := timeNow(c)
+ if err := updateManager(c, ns, req.Name, func(mgr *Manager, stats *ManagerStats) {
+ mgr.LastAlive = now
+ mgr.CurrentUpTime = req.UpTime
+ if cur := int64(req.Corpus); cur > stats.MaxCorpus {
+ stats.MaxCorpus = cur
+ }
+ if cur := int64(req.Cover); cur > stats.MaxCover {
+ stats.MaxCover = cur
+ }
+ stats.TotalFuzzingTime += req.FuzzingTime
+ stats.TotalCrashes += int64(req.Crashes)
+ stats.TotalExecs += int64(req.Execs)
+ }); err != nil {
+ return nil, err
+ }
+ return nil, nil
+}
+
func findBugForCrash(c context.Context, ns, title string) (*Bug, *datastore.Key, error) {
var bugs []*Bug
keys, err := datastore.NewQuery("Bug").