summaryrefslogtreecommitdiff
path: root/misc/dashboard
diff options
context:
space:
mode:
authorDave Cheney <dave@cheney.net>2013-02-05 20:50:20 +1100
committerDave Cheney <dave@cheney.net>2013-02-05 20:50:20 +1100
commitbaa0202ac3bfb564a58c5f4332cf1c4e8827250c (patch)
tree722972e8c887f546bab6b62c220e3177d778d669 /misc/dashboard
parentaf2d75e4068bc5f335dea95e35af5bcc071aa407 (diff)
downloadgo-baa0202ac3bfb564a58c5f4332cf1c4e8827250c.tar.gz
misc/dashboard/app: trim old builds from the history
The dashboard is currently failing to store results of new builds for some keys, notable the go.codereview sub repository. This is causing the builders to mark the entire triggering commit as failed. With the help of David Symonds we think it is because the results value has breached the 1mb datastore limit on AppEngine. R=dsymonds, adg CC=golang-dev https://codereview.appspot.com/6858094
Diffstat (limited to 'misc/dashboard')
-rw-r--r--misc/dashboard/app/build/build.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/misc/dashboard/app/build/build.go b/misc/dashboard/app/build/build.go
index 53db3dda5..3ac9cc241 100644
--- a/misc/dashboard/app/build/build.go
+++ b/misc/dashboard/app/build/build.go
@@ -119,19 +119,35 @@ func (c *Commit) Valid() error {
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
+
// AddResult adds the denormalized Reuslt data to the Commit's Result field.
// It must be called from inside a datastore transaction.
func (com *Commit) AddResult(c appengine.Context, r *Result) error {
if err := datastore.Get(c, com.Key(c), com); err != nil {
return fmt.Errorf("getting Commit: %v", err)
}
- com.ResultData = append(com.ResultData, r.Data())
+ 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
}
+func trim(s []string, n int) []string {
+ l := min(len(s), n)
+ return s[len(s)-l:]
+}
+
+func min(a, b int) int {
+ if a < b {
+ return a
+ }
+ return b
+}
+
// Result returns the build Result for this Commit for the given builder/goHash.
func (c *Commit) Result(builder, goHash string) *Result {
for _, r := range c.ResultData {