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

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

Issue 2250263005: Milo: Prefetch logs that are failures (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Also add prefetch Created 4 years, 4 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
Index: milo/appengine/swarming/build.go
diff --git a/milo/appengine/swarming/build.go b/milo/appengine/swarming/build.go
index afd1745f145a70d84d6db9685d48ea1466cd3795..2e7dc50da911a8a75040aa09dc4eb5ff614136dd 100644
--- a/milo/appengine/swarming/build.go
+++ b/milo/appengine/swarming/build.go
@@ -397,11 +397,14 @@ func streamsFromAnnotatedLog(ctx context.Context, log string) (*logdog.Streams,
return c.ToLogDogStreams()
}
-func swarmingBuildImpl(c context.Context, linkBase, server, taskID string) (*resp.MiloBuild, error) {
+// swarmingBuildImpl fetches a swarming task from a swarming server, parses
+// the logs via Annotee, and returns a build response, along with a list of
+// URLs to prefetch.
agable 2016/08/18 21:44:11 Any reason the list of urls isn't part of an "inte
Ryan Tseng 2016/08/18 22:09:45 Originally the thought was that this would manifes
+func swarmingBuildImpl(c context.Context, linkBase, server, taskID string) (*resp.MiloBuild, []string, error) {
// Fetch the data from Swarming
sr, body, err := getSwarming(c, server, taskID)
if err != nil {
- return nil, err
+ return nil, nil, err
}
allowMilo := false
@@ -412,7 +415,7 @@ func swarmingBuildImpl(c context.Context, linkBase, server, taskID string) (*res
}
}
if !allowMilo {
- return nil, fmt.Errorf("Not A Milo Job")
+ return nil, nil, fmt.Errorf("Not A Milo Job")
}
var build resp.MiloBuild
@@ -439,17 +442,29 @@ func swarmingBuildImpl(c context.Context, linkBase, server, taskID string) (*res
}
if err := addTaskToMiloStep(c, server, sr, lds.MainStream.Data); err != nil {
- return nil, err
+ return nil, nil, err
}
logdog.AddLogDogToBuild(c, swarmingURLBuilder(linkBase), lds, &build)
}
}
if err := addTaskToBuild(c, server, sr, &build); err != nil {
- return nil, err
+ return nil, nil, err
+ }
+
+ // Extract links that are failures or exceptions for prefetching.
+ prefetch := []string{}
+ for _, step := range build.Components {
+ if len(prefetch) > 3 {
+ break // Don't prefetch more than 3 things.
+ }
+ switch step.Status {
+ case resp.Failure, resp.InfraFailure:
+ prefetch = append(prefetch, step.MainLink.URL)
+ }
}
- return &build, nil
+ return &build, prefetch, nil
}
// taskPageURL returns a URL to a human-consumable page of a swarming task.

Powered by Google App Engine
This is Rietveld 408576698