Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(819)

Unified Diff: milo/appengine/buildbot/build.go

Issue 2772623002: Milo: Don't float step times if build has finished (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | milo/appengine/buildbot/builder.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/buildbot/build.go
diff --git a/milo/appengine/buildbot/build.go b/milo/appengine/buildbot/build.go
index c6f7e0c977bd902aaa08dbc5e956b1119dfebc83..849d8df1dd9942d5e028d9ff810a9d21184de337 100644
--- a/milo/appengine/buildbot/build.go
+++ b/milo/appengine/buildbot/build.go
@@ -66,9 +66,21 @@ func result2Status(s *int) (status resp.Status) {
return
}
+// buildbotTimeToTime converts a buildbot time representation (pointer to float
+// of seconds since epoch) to a natime time.Time object.
nodir 2017/03/24 06:23:49 native
hinoka 2017/03/28 18:18:36 Done.
+func buildbotTimeToTime(t *float64) (result time.Time) {
+ if t != nil {
+ result = time.Unix(int64(*t), int64(*t*1e9)%1e9).UTC()
nodir 2017/03/24 06:23:49 I think this needs gofmt
hinoka 2017/03/28 18:18:36 Just did... nothing changed. (It's also a write ho
+ }
+ return
+}
+
// parseTimes translates a buildbot time tuple (start/end) into a triplet
nodir 2017/03/24 06:23:49 nit: standard notation is that tuple item separato
hinoka 2017/03/28 18:18:36 Done.
// of (Started time, Ending time, duration).
-func parseTimes(times []*float64) (started, ended time.Time, duration time.Duration) {
+// If buildFinished is not nil, then all non-specified end duration will be set to
nodir 2017/03/24 06:23:49 it says "all" like there are multiple end duration
hinoka 2017/03/28 18:18:36 Done.
+// buildFinished. This is so that completed builds never have open step ending
+// times.
+func parseTimes(buildFinished *float64, times []*float64) (started, ended time.Time, duration time.Duration) {
if len(times) != 2 {
panic(fmt.Errorf("Expected 2 floats for times, got %v", times))
}
@@ -76,11 +88,15 @@ func parseTimes(times []*float64) (started, ended time.Time, duration time.Durat
// Some steps don't have timing info. In that case, just return nils.
return
}
- started = time.Unix(int64(*times[0]), int64(*times[0]*1e9)%1e9).UTC()
- if times[1] != nil {
- ended = time.Unix(int64(*times[1]), int64(*times[1]*1e9)%1e9).UTC()
+ started = buildbotTimeToTime(times[0])
+ switch {
+ case times[1] != nil:
+ ended = buildbotTimeToTime(times[1])
duration = ended.Sub(started)
- } else {
+ case buildFinished != nil:
+ ended = buildbotTimeToTime(buildFinished)
+ duration = ended.Sub(started)
+ default:
duration = time.Since(started)
}
return
@@ -126,7 +142,7 @@ func summary(c context.Context, b *buildbotBuild) resp.BuildComponent {
}
// Timing info
- started, ended, duration := parseTimes(b.Times)
+ started, ended, duration := parseTimes(nil, b.Times)
// Link to bot and original build.
server := "build.chromium.org/p"
@@ -181,6 +197,7 @@ var rLineBreak = regexp.MustCompile("<br */?>")
// components takes a full buildbot build struct and extract step info from all
// of the steps and returns it as a list of milo Build Components.
func components(b *buildbotBuild) (result []*resp.BuildComponent) {
+ endingTime := b.Times[1]
for i, step := range b.Steps {
if step.Hidden == true {
continue
@@ -320,7 +337,7 @@ func components(b *buildbotBuild) (result []*resp.BuildComponent) {
}
// Figure out the times.
- bc.Started, bc.Finished, bc.Duration = parseTimes(step.Times)
+ bc.Started, bc.Finished, bc.Duration = parseTimes(endingTime, step.Times)
result = append(result, bc)
}
« no previous file with comments | « no previous file | milo/appengine/buildbot/builder.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698