diff --git a/prow/pjutil/jobspec.go b/prow/pjutil/jobspec.go index 50b5ce6dd001b..8759589c75eea 100644 --- a/prow/pjutil/jobspec.go +++ b/prow/pjutil/jobspec.go @@ -23,6 +23,7 @@ import ( "io/ioutil" "net/http" "os" + "path" "strconv" "time" @@ -63,10 +64,12 @@ func NewJobSpec(spec kube.ProwJobSpec, buildId, prowJobId string) JobSpec { // to vend build identifier for the job func GetBuildID(name, totURL string) (string, error) { var err error - url := totURL + "/vend/" + name - for retries := 0; retries < 60; retries++ { + url := path.Join(totURL, "vend", name) + sleep := 100 * time.Millisecond + for retries := 0; retries < 10; retries++ { if retries > 0 { - time.Sleep(2 * time.Second) + time.Sleep(sleep) + sleep = sleep * 2 } var resp *http.Response resp, err = http.Get(url) @@ -75,9 +78,12 @@ func GetBuildID(name, totURL string) (string, error) { } defer resp.Body.Close() if resp.StatusCode != 200 { + err = fmt.Errorf("got unexpected response from tot: %v", resp.Status) continue } - if buf, err := ioutil.ReadAll(resp.Body); err == nil { + var buf []byte + buf, err = ioutil.ReadAll(resp.Body) + if err == nil { return string(buf), nil } return "", err