Skip to content

Commit c3d2f80

Browse files
committed
internal/relui: set a deadline on artifact presence checks
We saw some signs of requests hanging when we tried it out. Make sure we don't get stuck forever. For golang/go#51797. Change-Id: I24994105beee643b915dd17d520eb08843b0d864 Reviewed-on: https://go-review.googlesource.com/c/build/+/411895 Run-TryBot: Heschi Kreinick <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 2853c38 commit c3d2f80

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/relui/workflows.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package relui
66

77
import (
8+
"context"
89
"crypto/sha256"
910
"fmt"
1011
"io"
@@ -25,6 +26,7 @@ import (
2526
"golang.org/x/build/internal/relui/db"
2627
"golang.org/x/build/internal/task"
2728
"golang.org/x/build/internal/workflow"
29+
"golang.org/x/net/context/ctxhttp"
2830
)
2931

3032
// DefinitionHolder holds workflow definitions.
@@ -735,11 +737,14 @@ func (tasks *BuildReleaseTasks) uploadArtifacts(ctx *workflow.TaskContext, artif
735737

736738
for {
737739
for _, a := range artifacts {
738-
resp, err := http.Head(tasks.DownloadURL + "/" + a.Filename)
739-
if err != nil {
740+
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
741+
defer cancel()
742+
resp, err := ctxhttp.Head(ctx, http.DefaultClient, tasks.DownloadURL+"/"+a.Filename)
743+
if err != nil && err != context.DeadlineExceeded {
740744
return err
741745
}
742746
resp.Body.Close()
747+
cancel()
743748
if resp.StatusCode == http.StatusOK {
744749
delete(todo, a)
745750
}

0 commit comments

Comments
 (0)