Merge pull request #81347 from jfbai/tob-k8s-003

Add http response code 301 and 503 to check.
This commit is contained in:
Kubernetes Prow Robot 2019-08-15 23:08:45 -07:00 committed by GitHub
commit b0dbdbeb00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -129,7 +129,10 @@ func newWalkFunc(invalidLink *bool, client *http.Client) filepath.WalkFunc {
if err != nil { if err != nil {
break break
} }
if resp.StatusCode == http.StatusTooManyRequests { // This header is used in 301, 429 and 503.
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After
// And Go client will follow redirects automatically so the 301 check is probably unnecessary.
if resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode == http.StatusServiceUnavailable {
retryAfter := resp.Header.Get("Retry-After") retryAfter := resp.Header.Get("Retry-After")
if seconds, err := strconv.Atoi(retryAfter); err != nil { if seconds, err := strconv.Atoi(retryAfter); err != nil {
backoff = seconds + 10 backoff = seconds + 10