Skip to content

Commit

Permalink
[JENKINS-6798] Redirect on HTTP 502, 503, 504 (#4366)
Browse files Browse the repository at this point in the history
* [JENKINS-6798] Redirect on HTTP >= 502 (502, 503, 504)

When Jenkins is behind a reverse proxy and is not available or
restarting, the reverse proxy will answer a HTTP 502 (because the upstream
doesn't answer).

* Add upper bound
  • Loading branch information
Vlatombe authored and oleg-nenashev committed Nov 29, 2019
1 parent 038109d commit b4e4d78
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion war/src/main/webapp/scripts/hudson-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -2778,7 +2778,7 @@ function applySafeRedirector(url) {
new Ajax.Request(url, {
method: "get",
onFailure: function(rsp) {
if(rsp.status==503 && rsp.getHeader("X-Jenkins-Interactive")==null) {
if((rsp.status >= 502 && rsp.status <= 504) && rsp.getHeader("X-Jenkins-Interactive")==null) {
// redirect as long as we are still loading
window.setTimeout(statusChecker,5000);
} else {
Expand Down
2 changes: 1 addition & 1 deletion war/src/main/webapp/scripts/loading.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function safeRedirector(url) {
window.setTimeout(function() {
const statusChecker = arguments.callee;
Fetch.get(url, function(error, status) {
if(status === 503 || status === 0) {
if((status >= 502 && status <= 504) || status === 0) {
window.setTimeout(statusChecker, timeout)
} else {
window.location.replace(url);
Expand Down

0 comments on commit b4e4d78

Please sign in to comment.