From 4e0a77820c14a4949c590a7beacb75a31502e9cf Mon Sep 17 00:00:00 2001 From: clover caruso Date: Tue, 6 Oct 2026 23:11:12 -0700 Subject: [PATCH] Keep single-upstream routes reachable after transient failures --- tools/router.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/router.py b/tools/router.py index 00707cb860dcfc7e8d594a5561e92fcfacc38770..25872312f190dd4251d4b44fbc9bdd60e5e379b7 100644 --- a/tools/router.py +++ b/tools/router.py @@ -24,9 +24,13 @@ def nomad(path, token): return json.load(response) +def passive_health(upstreams, indent): + return [f"{indent}fail_duration 30s"] if len(upstreams.split()) > 1 else [] + + def proxy(upstreams, indent, uncompressed=False, host=None): lines = [f"{indent}reverse_proxy {upstreams} {{", f"{indent} lb_try_duration 5s", - f"{indent} fail_duration 30s"] + *passive_health(upstreams, indent + " ")] if uncompressed: lines.append(f"{indent} header_up Accept-Encoding identity") if host: @@ -261,7 +265,7 @@ def render(token): if route["userHeader"]: lines.append(f" request_header -{route['userHeader']}") lines += [ - f" reverse_proxy {auth} {{", " lb_try_duration 5s", " fail_duration 30s", " method GET", + f" reverse_proxy {auth} {{", " lb_try_duration 5s", *passive_health(auth, " "), " method GET", " rewrite /snow.oauth2/auth", " header_up X-Forwarded-Method {method}", " header_up X-Forwarded-Uri {uri}", " @unauthorized status 401", " handle_response @unauthorized {", @@ -286,7 +290,7 @@ def render(token): lines += [" handle /snow.oauth2/* {", *proxy(auth," "), " }"] lines += [" handle {"] lines += [f" request_header -{name}" for name in scrub] - lines += [f" reverse_proxy {auth} {{", " lb_try_duration 5s", " fail_duration 30s", " method GET", " rewrite " + ("/auth/file/check" if native else "/snow.oauth2/auth"), + lines += [f" reverse_proxy {auth} {{", " lb_try_duration 5s", *passive_health(auth, " "), " method GET", " rewrite " + ("/auth/file/check" if native else "/snow.oauth2/auth"), *([f" header_up Studio-Proxy-Token {dashboard_proof}"] if native else []), " header_up X-Forwarded-Method {method}", " header_up X-Forwarded-Uri {uri}", " @authenticated status 2xx", " handle_response @authenticated {"] -- 2.54.0