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

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

Issue 2675493003: milo: Use service interface for swarming. (Closed)
Patch Set: Created 3 years, 11 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/buildLog.go
diff --git a/milo/appengine/swarming/buildLog.go b/milo/appengine/swarming/buildLog.go
index 666ad747a647cca1dfbcd9f6c7350dd4a0745b70..c99ca84893456830a629f34f5c344f8704beb6f5 100644
--- a/milo/appengine/swarming/buildLog.go
+++ b/milo/appengine/swarming/buildLog.go
@@ -8,19 +8,18 @@ import (
"fmt"
"path"
"sort"
- "strings"
"golang.org/x/net/context"
mc "github.com/luci/gae/service/memcache"
- "github.com/luci/luci-go/common/api/swarming/swarming/v1"
"github.com/luci/luci-go/common/logging"
)
// swarmingBuildLogImpl is the implementation for getting a log name from
// a swarming build via annotee. It returns the full text of the specific log,
// and whether or not it has been closed.
-func swarmingBuildLogImpl(c context.Context, server, taskID, logname string) (string, bool, error) {
+func swarmingBuildLogImpl(c context.Context, svc swarmingService, taskID, logname string) (string, bool, error) {
+ server := svc.getHost()
cached, err := mc.GetKey(c, path.Join("swarmingLog", server, taskID, logname))
switch {
case err == mc.ErrCacheMiss:
@@ -33,25 +32,16 @@ func swarmingBuildLogImpl(c context.Context, server, taskID, logname string) (st
return string(cached.Value()), false, nil
}
- var sc *swarming.Service
- debug := strings.HasPrefix(taskID, "debug:")
- if debug {
- // if taskID starts with "debug:", then getTaskOutput will ignore client.
- } else {
- var err error
- sc, err = getSwarmingClient(c, server)
- if err != nil {
- return "", false, err
- }
+ fetch := swarmingFetch{
+ fetchRes: true, // Needed so we can validate that this is a Milo build.
+ fetchLog: true,
}
-
- output, err := getTaskOutput(sc, taskID)
- if err != nil {
+ if err := fetch.get(c, svc, taskID); err != nil {
return "", false, err
}
// Decode the data using annotee.
- s, err := streamsFromAnnotatedLog(c, output)
+ s, err := streamsFromAnnotatedLog(c, fetch.log)
if err != nil {
return "", false, err
}
@@ -67,7 +57,7 @@ func swarmingBuildLogImpl(c context.Context, server, taskID, logname string) (st
return "", false, fmt.Errorf("stream %q not found; available streams: %q", k, keys)
}
- if stream.Closed && !debug {
+ if stream.Closed {
cached.SetValue([]byte(stream.Text))
if err := mc.Set(c, cached); err != nil {
logging.Errorf(c, "Failed to write log with key %s to memcache: %s", cached.Key(), err)

Powered by Google App Engine
This is Rietveld 408576698