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

Side by Side Diff: milo/appengine/swarming/html.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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package swarming 5 package swarming
6 6
7 import ( 7 import (
8 "net/http" 8 "net/http"
9 "os" 9 "os"
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 func (b Build) Render(c context.Context, r *http.Request, p httprouter.Params) ( *templates.Args, error) { 79 func (b Build) Render(c context.Context, r *http.Request, p httprouter.Params) ( *templates.Args, error) {
80 // Get the swarming ID 80 // Get the swarming ID
81 id := p.ByName("id") 81 id := p.ByName("id")
82 if id == "" { 82 if id == "" {
83 return nil, &miloerror.Error{ 83 return nil, &miloerror.Error{
84 Message: "No id", 84 Message: "No id",
85 Code: http.StatusBadRequest, 85 Code: http.StatusBadRequest,
86 } 86 }
87 } 87 }
88 88
89 » result, err := swarmingBuildImpl(c, r.URL.String(), getServer(r), id) 89 » result, prefetch, err := swarmingBuildImpl(c, r.URL.String(), getServer( r), id)
90 if err != nil { 90 if err != nil {
91 return nil, convertErr(err) 91 return nil, convertErr(err)
92 } 92 }
93 93
94 // Render into the template 94 // Render into the template
95 args := &templates.Args{ 95 args := &templates.Args{
96 » » "Build": result, 96 » » "Build": result,
97 » » "Prefetch": prefetch,
97 } 98 }
98 return args, nil 99 return args, nil
99 } 100 }
100 101
101 func convertErr(err error) error { 102 func convertErr(err error) error {
102 if isAPINotFound(err) || os.IsNotExist(err) { 103 if isAPINotFound(err) || os.IsNotExist(err) {
103 return &miloerror.Error{ 104 return &miloerror.Error{
104 Message: err.Error(), 105 Message: err.Error(),
105 Code: http.StatusNotFound, 106 Code: http.StatusNotFound,
106 } 107 }
107 } 108 }
108 return err 109 return err
109 } 110 }
110 111
111 // isAPINotFound returns true if err is a HTTP 404 API response. 112 // isAPINotFound returns true if err is a HTTP 404 API response.
112 func isAPINotFound(err error) bool { 113 func isAPINotFound(err error) bool {
113 if apiErr, ok := err.(*googleapi.Error); ok && apiErr.Code == http.Statu sNotFound { 114 if apiErr, ok := err.(*googleapi.Error); ok && apiErr.Code == http.Statu sNotFound {
114 return true 115 return true
115 } 116 }
116 117
117 return false 118 return false
118 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698