aboutsummaryrefslogtreecommitdiffstats
path: root/dashboard
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-11-27 16:40:04 +0100
committerDmitry Vyukov <dvyukov@google.com>2019-11-27 16:40:04 +0100
commit0d63f89cabcbc3e57201973370a309b646cc43c9 (patch)
tree3eb549e19dc354cf37fa9c735ea2f7cf3b901a5b /dashboard
parent4cea005389a2c907bf947f6f2b79ef2bc9e42ce1 (diff)
syz-ci: allow enabling bisect cause and fix jobs separately
Some backport-only kernels may only be interested in fix bisections. Allow enabling these separately.
Diffstat (limited to 'dashboard')
-rw-r--r--dashboard/app/api.go4
-rw-r--r--dashboard/app/bisect_test.go1
-rw-r--r--dashboard/app/jobs.go56
-rw-r--r--dashboard/app/util_test.go14
-rw-r--r--dashboard/dashapi/dashapi.go9
5 files changed, 50 insertions, 34 deletions
diff --git a/dashboard/app/api.go b/dashboard/app/api.go
index f8a59a3e9..09313b6a6 100644
--- a/dashboard/app/api.go
+++ b/dashboard/app/api.go
@@ -357,10 +357,10 @@ func apiJobPoll(c context.Context, r *http.Request, payload []byte) (interface{}
if err := json.Unmarshal(payload, req); err != nil {
return nil, fmt.Errorf("failed to unmarshal request: %v", err)
}
- if len(req.PatchTestManagers) == 0 && len(req.BisectManagers) == 0 {
+ if len(req.Managers) == 0 {
return nil, fmt.Errorf("no managers")
}
- return pollPendingJobs(c, req.PatchTestManagers, req.BisectManagers)
+ return pollPendingJobs(c, req.Managers)
}
func apiJobDone(c context.Context, r *http.Request, payload []byte) (interface{}, error) {
diff --git a/dashboard/app/bisect_test.go b/dashboard/app/bisect_test.go
index 88aedc7fb..b385aa655 100644
--- a/dashboard/app/bisect_test.go
+++ b/dashboard/app/bisect_test.go
@@ -771,6 +771,7 @@ func TestBisectCauseExternal(t *testing.T) {
rep := c.client.pollBug()
pollResp := c.client.pollJobs(build.Manager)
+ c.expectNE(pollResp.ID, "")
jobID := pollResp.ID
done := &dashapi.JobDoneReq{
ID: jobID,
diff --git a/dashboard/app/jobs.go b/dashboard/app/jobs.go
index 7c7c011c0..4a31d8ff1 100644
--- a/dashboard/app/jobs.go
+++ b/dashboard/app/jobs.go
@@ -186,17 +186,10 @@ func checkTestJob(c context.Context, bug *Bug, bugReporting *BugReporting, crash
}
// pollPendingJobs returns the next job to execute for the provided list of managers.
-func pollPendingJobs(c context.Context, testMgrs, bisectMgrs []string) (*dashapi.JobPollResp, error) {
- testManagers := make(map[string]bool)
- for _, mgr := range testMgrs {
- testManagers[mgr] = true
- }
- bisectManagers := make(map[string]bool)
- for _, mgr := range bisectMgrs {
- bisectManagers[mgr] = true
- }
+func pollPendingJobs(c context.Context, managers map[string]dashapi.ManagerJobs) (
+ *dashapi.JobPollResp, error) {
retry:
- job, jobKey, err := getNextJob(c, testManagers, bisectManagers)
+ job, jobKey, err := getNextJob(c, managers)
if job == nil || err != nil {
return nil, err
}
@@ -210,35 +203,45 @@ retry:
return resp, nil
}
-func getNextJob(c context.Context, testManagers, bisectManagers map[string]bool) (*Job, *db.Key, error) {
- job, jobKey, err := loadPendingJob(c, testManagers, bisectManagers)
+func getNextJob(c context.Context, managers map[string]dashapi.ManagerJobs) (*Job, *db.Key, error) {
+ job, jobKey, err := loadPendingJob(c, managers)
if job != nil || err != nil {
return job, jobKey, err
}
- if len(bisectManagers) == 0 {
- return nil, nil, nil
- }
// We need both C and syz repros, but the crazy datastore query restrictions
// do not allow to use ReproLevel>ReproLevelNone in the query. So we do 2 separate queries.
// C repros tend to be of higher reliability so maybe it's not bad.
- job, jobKey, err = createBisectJob(c, bisectManagers, ReproLevelC)
+ job, jobKey, err = createBisectJob(c, managers, ReproLevelC)
if job != nil || err != nil {
return job, jobKey, err
}
- return createBisectJob(c, bisectManagers, ReproLevelSyz)
+ return createBisectJob(c, managers, ReproLevelSyz)
}
-func createBisectJob(c context.Context, managers map[string]bool, reproLevel dashapi.ReproLevel) (
- *Job, *db.Key, error) {
- job, jobKey, err := findBugsForBisection(c, managers, reproLevel, JobBisectCause)
+func createBisectJob(c context.Context, managers map[string]dashapi.ManagerJobs,
+ reproLevel dashapi.ReproLevel) (*Job, *db.Key, error) {
+ causeManagers := make(map[string]bool)
+ fixManagers := make(map[string]bool)
+ for mgr, jobs := range managers {
+ if jobs.BisectCause {
+ causeManagers[mgr] = true
+ }
+ if jobs.BisectFix {
+ fixManagers[mgr] = true
+ }
+ }
+ job, jobKey, err := findBugsForBisection(c, causeManagers, reproLevel, JobBisectCause)
if job != nil || err != nil {
return job, jobKey, err
}
- return findBugsForBisection(c, managers, reproLevel, JobBisectFix)
+ return findBugsForBisection(c, fixManagers, reproLevel, JobBisectFix)
}
-func findBugsForBisection(c context.Context, managers map[string]bool, reproLevel dashapi.ReproLevel, jobType JobType) (
- *Job, *db.Key, error) {
+func findBugsForBisection(c context.Context, managers map[string]bool,
+ reproLevel dashapi.ReproLevel, jobType JobType) (*Job, *db.Key, error) {
+ if len(managers) == 0 {
+ return nil, nil, nil
+ }
// Note: we could also include len(Commits)==0 but datastore does not work this way.
// So we would need an additional HasCommits field or something.
// Note: For JobBisectCause, order the bugs from newest to oldest. For JobBisectFix,
@@ -762,7 +765,7 @@ func jobReported(c context.Context, jobID string) error {
return db.RunInTransaction(c, tx, nil)
}
-func loadPendingJob(c context.Context, testManagers, bisectManagers map[string]bool) (*Job, *db.Key, error) {
+func loadPendingJob(c context.Context, managers map[string]dashapi.ManagerJobs) (*Job, *db.Key, error) {
var jobs []*Job
keys, err := db.NewQuery("Job").
Filter("Finished=", time.Time{}).
@@ -775,11 +778,12 @@ func loadPendingJob(c context.Context, testManagers, bisectManagers map[string]b
for i, job := range jobs {
switch job.Type {
case JobTestPatch:
- if !testManagers[job.Manager] {
+ if !managers[job.Manager].TestPatches {
continue
}
case JobBisectCause, JobBisectFix:
- if !bisectManagers[job.Manager] {
+ if job.Type == JobBisectCause && !managers[job.Manager].BisectCause ||
+ job.Type == JobBisectFix && !managers[job.Manager].BisectFix {
continue
}
// Don't retry bisection jobs too often.
diff --git a/dashboard/app/util_test.go b/dashboard/app/util_test.go
index 1d98b0e6d..c80ab6a95 100644
--- a/dashboard/app/util_test.go
+++ b/dashboard/app/util_test.go
@@ -392,10 +392,16 @@ func (client *apiClient) updateBug(extID string, status dashapi.BugStatus, dup s
}
func (client *apiClient) pollJobs(manager string) *dashapi.JobPollResp {
- resp, err := client.JobPoll(&dashapi.JobPollReq{
- PatchTestManagers: []string{manager},
- BisectManagers: []string{manager},
- })
+ req := &dashapi.JobPollReq{
+ Managers: map[string]dashapi.ManagerJobs{
+ manager: {
+ TestPatches: true,
+ BisectCause: true,
+ BisectFix: true,
+ },
+ },
+ }
+ resp, err := client.JobPoll(req)
client.expectOK(err)
return resp
}
diff --git a/dashboard/dashapi/dashapi.go b/dashboard/dashapi/dashapi.go
index 833dd099f..8b93f0ae2 100644
--- a/dashboard/dashapi/dashapi.go
+++ b/dashboard/dashapi/dashapi.go
@@ -122,8 +122,13 @@ func (dash *Dashboard) BuilderPoll(manager string) (*BuilderPollResp, error) {
// ID must match JobPollResp.ID.
type JobPollReq struct {
- PatchTestManagers []string
- BisectManagers []string
+ Managers map[string]ManagerJobs
+}
+
+type ManagerJobs struct {
+ TestPatches bool
+ BisectCause bool
+ BisectFix bool
}
type JobPollResp struct {