mirror of
https://github.com/golang/go
synced 2024-11-18 19:14:40 -07:00
dashboard: ensure that we ever store valid commits
LGTM=bradfitz R=bradfitz CC=golang-codereviews, rsc https://golang.org/cl/160960043
This commit is contained in:
parent
444afab9dd
commit
e2b4e09ae1
@ -127,6 +127,19 @@ func (c *Commit) Valid() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func putCommit(c appengine.Context, com *Commit) error {
|
||||
if err := com.Valid(); err != nil {
|
||||
return fmt.Errorf("putting Commit: %v", err)
|
||||
}
|
||||
if com.Num == 0 {
|
||||
return fmt.Errorf("putting Commit: com.Num == 0")
|
||||
}
|
||||
if _, err := datastore.Put(c, com.Key(c), com); err != nil {
|
||||
return fmt.Errorf("putting Commit: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// each result line is approx 105 bytes. This constant is a tradeoff between
|
||||
// build history and the AppEngine datastore limit of 1mb.
|
||||
const maxResults = 1000
|
||||
@ -150,10 +163,7 @@ func (com *Commit) AddResult(c appengine.Context, r *Result) error {
|
||||
// otherwise, add the new result data for this builder.
|
||||
com.ResultData = trim(append(com.ResultData, r.Data()), maxResults)
|
||||
}
|
||||
if _, err := datastore.Put(c, com.Key(c), com); err != nil {
|
||||
return fmt.Errorf("putting Commit: %v", err)
|
||||
}
|
||||
return nil
|
||||
return putCommit(c, com)
|
||||
}
|
||||
|
||||
// AddPerfResult remembers that the builder has run the benchmark on the commit.
|
||||
@ -172,10 +182,7 @@ func (com *Commit) AddPerfResult(c appengine.Context, builder, benchmark string)
|
||||
}
|
||||
}
|
||||
com.PerfResults = append(com.PerfResults, s)
|
||||
if _, err := datastore.Put(c, com.Key(c), com); err != nil {
|
||||
return fmt.Errorf("putting Commit: %v", err)
|
||||
}
|
||||
return nil
|
||||
return putCommit(c, com)
|
||||
}
|
||||
|
||||
func trim(s []string, n int) []string {
|
||||
|
@ -192,8 +192,8 @@ func addCommit(c appengine.Context, com *Commit) error {
|
||||
}
|
||||
}
|
||||
// put the Commit
|
||||
if _, err = datastore.Put(c, com.Key(c), com); err != nil {
|
||||
return fmt.Errorf("putting Commit: %v", err)
|
||||
if err = putCommit(c, com); err != nil {
|
||||
return err
|
||||
}
|
||||
if com.NeedsBenchmarking {
|
||||
// add to CommitRun
|
||||
|
@ -230,8 +230,7 @@ func commonNotify(c appengine.Context, com *Commit, builder, logHash string) err
|
||||
c.Infof("%s is broken commit; notifying", com.Hash)
|
||||
notifyLater.Call(c, com, builder, logHash) // add task to queue
|
||||
com.FailNotificationSent = true
|
||||
_, err := datastore.Put(c, com.Key(c), com)
|
||||
return err
|
||||
return putCommit(c, com)
|
||||
}
|
||||
|
||||
// sendFailMail sends a mail notification that the build failed on the
|
||||
|
@ -58,8 +58,8 @@ func updateBenchmark(w http.ResponseWriter, r *http.Request) {
|
||||
continue
|
||||
}
|
||||
com.NeedsBenchmarking = true
|
||||
if _, err := datastore.Put(c, com.Key(c), com); err != nil {
|
||||
return fmt.Errorf("putting Commit: %v", err)
|
||||
if err := putCommit(c, com); err != nil {
|
||||
return err
|
||||
}
|
||||
ncommit++
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user