aboutsummaryrefslogtreecommitdiffstats
path: root/syz-cluster/controller/api.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-01-15 17:41:31 +0100
committerAleksandr Nogikh <nogikh@google.com>2025-01-22 13:17:53 +0000
commitcc143e38041972ad4dbaff9cfbfd416c29d581b5 (patch)
tree31e07572a22bebdc20c1fc73a6ef9140c03eb3e5 /syz-cluster/controller/api.go
parent6bab9518e47d67b3c9bba00f213aa3e1637063e1 (diff)
syz-cluster: add support for findings
Findings are crashes and build/boot/test errors that happened during the patch series processing.
Diffstat (limited to 'syz-cluster/controller/api.go')
-rw-r--r--syz-cluster/controller/api.go40
1 files changed, 25 insertions, 15 deletions
diff --git a/syz-cluster/controller/api.go b/syz-cluster/controller/api.go
index 6f1089bd2..9db06c230 100644
--- a/syz-cluster/controller/api.go
+++ b/syz-cluster/controller/api.go
@@ -1,6 +1,7 @@
// Copyright 2024 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+// nolint: dupl // The methods look similar, but extracting the common parts will only make the code worse.
package main
import (
@@ -12,20 +13,21 @@ import (
"github.com/google/syzkaller/syz-cluster/pkg/api"
"github.com/google/syzkaller/syz-cluster/pkg/app"
- "github.com/google/syzkaller/syz-cluster/pkg/db"
)
type ControllerAPI struct {
- seriesService *SeriesService
- buildService *BuildService
- testRepo *db.SessionTestRepository
+ seriesService *SeriesService
+ buildService *BuildService
+ testService *SessionTestService
+ findingService *FindingService
}
func NewControllerAPI(env *app.AppEnvironment) *ControllerAPI {
return &ControllerAPI{
- seriesService: NewSeriesService(env),
- buildService: NewBuildService(env),
- testRepo: db.NewSessionTestRepository(env.Spanner),
+ seriesService: NewSeriesService(env),
+ buildService: NewBuildService(env),
+ testService: NewSessionTestService(env),
+ findingService: NewFindingService(env),
}
}
@@ -36,6 +38,7 @@ func (c ControllerAPI) Mux() *http.ServeMux {
mux.HandleFunc("/builds/last", c.getLastBuild)
mux.HandleFunc("/builds/upload", c.uploadBuild)
mux.HandleFunc("/tests/upload", c.uploadTest)
+ mux.HandleFunc("/findings/upload", c.uploadFinding)
return mux
}
@@ -85,15 +88,22 @@ func (c ControllerAPI) uploadTest(w http.ResponseWriter, r *http.Request) {
return
}
// TODO: add parameters validation.
- err := c.testRepo.Insert(context.Background(), &db.SessionTest{
- SessionID: req.SessionID,
- BaseBuildID: req.BaseBuildID,
- PatchedBuildID: req.PatchedBuildID,
- TestName: req.TestName,
- Result: req.Result,
- })
+ err := c.testService.Save(context.Background(), req)
+ if err != nil {
+ http.Error(w, fmt.Sprint(err), http.StatusInternalServerError)
+ return
+ }
+ reply[interface{}](w, nil)
+}
+
+func (c ControllerAPI) uploadFinding(w http.ResponseWriter, r *http.Request) {
+ req := parseBody[api.Finding](w, r)
+ if req == nil {
+ return
+ }
+ // TODO: add parameters validation.
+ err := c.findingService.Save(context.Background(), req)
if err != nil {
- // TODO: sometimes it's not StatusInternalServerError.
http.Error(w, fmt.Sprint(err), http.StatusInternalServerError)
return
}