aboutsummaryrefslogtreecommitdiff
path: root/internal/worker/server.go
diff options
context:
space:
mode:
authorRob Findley <rfindley@google.com>2023-04-14 10:50:05 -0400
committerRobert Findley <rfindley@google.com>2023-04-14 18:31:33 +0000
commit18cc5dd5fb68875841bcae0b2dd30aeb6ead68e9 (patch)
tree4c17c1dbbab1e616cace1fd3c38a6c9f443ebf4b /internal/worker/server.go
parentc8c7dd529a73cc1a912f7b53ca9d419d59fdc263 (diff)
downloadgo-x-pkgsite-18cc5dd5fb68875841bcae0b2dd30aeb6ead68e9.tar.xz
internal/worker: proxy timeouts should be retryable
When fetching e.g. the master branch, it is common for the proxy client to timeout as it waits for the branch to be resolved. This should be a retryable error, as otherwise we end up in a state where an asynchronous refresh of master actually breaks documentation at master. There is still a problem that documentation is broken after the first failure, but this at least puts us in a recoverable state. Again, as with CL 482162 this is unfortunately not possible to test in the current setup without significant refactoring. Such refactoring may be warranted, but I do not have time to do this now. Updates golang/go#59464 Change-Id: I321cc2eaabac1d7e052d07efcaadefcac24208ac Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/484736 Reviewed-by: Jamal Carvalho <jamal@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/worker/server.go')
-rw-r--r--internal/worker/server.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/worker/server.go b/internal/worker/server.go
index e6af6ce2..0bef928f 100644
--- a/internal/worker/server.go
+++ b/internal/worker/server.go
@@ -305,6 +305,16 @@ func (s *Server) handleFetch(w http.ResponseWriter, r *http.Request) {
http.Error(w, http.StatusText(code), code)
return
}
+
+ // Proxy timeouts are retryable, since they occur when e.g. a branch pointer
+ // such as master needs to be re-fetched.
+ if code == derrors.ToStatus(derrors.ProxyTimedOut) {
+ log.Infof(r.Context(), "doFetch of %s returned %d (proxy timeout); returning 500 retry task", r.URL.Path, code)
+ code := http.StatusInternalServerError
+ http.Error(w, http.StatusText(code), code)
+ return
+ }
+
if code/100 != 2 {
log.Infof(r.Context(), "doFetch of %s returned code %d; returning OK to avoid retry", r.URL.Path, code)
}