aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-03-12 13:23:20 +0100
committerDmitry Vyukov <dvyukov@google.com>2019-03-17 18:06:44 +0100
commit5cf6e34d9e776fa906088beff75fa93b4e3681c2 (patch)
treed4fd1db3af44154a8def02d132c70cb04e9108d3
parentd543ef91374057306631c795dbaa19467c509232 (diff)
dashboard/app: add markCrashReported helper
Factor out markCrashReported out of incomingCommandTx. Use it when creating patch testing jobs. Will be needed for bisection jobs as well. Update #501
-rw-r--r--dashboard/app/entities.go13
-rw-r--r--dashboard/app/jobs.go2
-rw-r--r--dashboard/app/reporting.go12
3 files changed, 16 insertions, 11 deletions
diff --git a/dashboard/app/entities.go b/dashboard/app/entities.go
index eb065fcdb..0ac817535 100644
--- a/dashboard/app/entities.go
+++ b/dashboard/app/entities.go
@@ -388,6 +388,19 @@ func (bug *Bug) getCommitInfo(i int) Commit {
return Commit{}
}
+func markCrashReported(c context.Context, crashID int64, bugKey *datastore.Key, now time.Time) error {
+ crash := new(Crash)
+ crashKey := datastore.NewKey(c, "Crash", "", crashID, bugKey)
+ if err := datastore.Get(c, crashKey, crash); err != nil {
+ return fmt.Errorf("failed to get reported crash %v: %v", crashID, err)
+ }
+ crash.Reported = now
+ if _, err := datastore.Put(c, crashKey, crash); err != nil {
+ return fmt.Errorf("failed to put reported crash %v: %v", crashID, err)
+ }
+ return nil
+}
+
func kernelRepoInfo(build *Build) KernelRepo {
return kernelRepoInfoRaw(build.Namespace, build.KernelRepo, build.KernelBranch)
}
diff --git a/dashboard/app/jobs.go b/dashboard/app/jobs.go
index 7427f05dd..5b0893f93 100644
--- a/dashboard/app/jobs.go
+++ b/dashboard/app/jobs.go
@@ -149,7 +149,7 @@ func addTestJob(c context.Context, bug *Bug, bugKey *datastore.Key, bugReporting
if _, err := datastore.Put(c, jobKey, job); err != nil {
return fmt.Errorf("failed to put job: %v", err)
}
- return nil
+ return markCrashReported(c, job.CrashID, bugKey, now)
}
err = datastore.RunInTransaction(c, tx, &datastore.TransactionOptions{XG: true, Attempts: 30})
if patchID != 0 && deletePatch || err != nil {
diff --git a/dashboard/app/reporting.go b/dashboard/app/reporting.go
index a75372413..461605721 100644
--- a/dashboard/app/reporting.go
+++ b/dashboard/app/reporting.go
@@ -619,16 +619,8 @@ func incomingCommandTx(c context.Context, now time.Time, cmd *dashapi.BugUpdate,
}
if cmd.CrashID != 0 {
// Rememeber that we've reported this crash.
- crash := new(Crash)
- crashKey := datastore.NewKey(c, "Crash", "", cmd.CrashID, bugKey)
- if err := datastore.Get(c, crashKey, crash); err != nil {
- return false, internalError, fmt.Errorf("failed to get reported crash %v: %v",
- cmd.CrashID, err)
- }
- crash.Reported = now
- if _, err := datastore.Put(c, crashKey, crash); err != nil {
- return false, internalError, fmt.Errorf("failed to put reported crash %v: %v",
- cmd.CrashID, err)
+ if err := markCrashReported(c, cmd.CrashID, bugKey, now); err != nil {
+ return false, internalError, err
}
bugReporting.CrashID = cmd.CrashID
}