authorclover caruso <git@paperclover.net> 2026-10-06 23:11:12-07:00
committerclover caruso <git@paperclover.net> 2026-10-09 11:21:14-07:00
log4e0a77820c14a4949c590a7beacb75a31502e9cf
treedb79b1df80bb83440b2b971352160f8fb6aad76e
parentd73490141270d3252e24a89690364d9abc417639
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU (~clover)

Keep single-upstream routes reachable after transient failures


1 files changed, 7 insertions(+), 3 deletions(-)

tools/router.py+7-3
......@@ -24,9 +24,13 @@ def nomad(path, token):
2424 return json.load(response)
2525
2626
27def passive_health(upstreams, indent):
28 return [f"{indent}fail_duration 30s"] if len(upstreams.split()) > 1 else []
29
30
2731def proxy(upstreams, indent, uncompressed=False, host=None):
2832 lines = [f"{indent}reverse_proxy {upstreams} {{", f"{indent} lb_try_duration 5s",
29 f"{indent} fail_duration 30s"]
33 *passive_health(upstreams, indent + " ")]
3034 if uncompressed:
3135 lines.append(f"{indent} header_up Accept-Encoding identity")
3236 if host:
......@@ -261,7 +265,7 @@ def render(token):
261265 if route["userHeader"]:
262266 lines.append(f" request_header -{route['userHeader']}")
263267 lines += [
264 f" reverse_proxy {auth} {{", " lb_try_duration 5s", " fail_duration 30s", " method GET",
268 f" reverse_proxy {auth} {{", " lb_try_duration 5s", *passive_health(auth, " "), " method GET",
265269 " rewrite /snow.oauth2/auth", " header_up X-Forwarded-Method {method}",
266270 " header_up X-Forwarded-Uri {uri}", " @unauthorized status 401",
267271 " handle_response @unauthorized {",
......@@ -286,7 +290,7 @@ def render(token):
286290 lines += [" handle /snow.oauth2/* {", *proxy(auth," "), " }"]
287291 lines += [" handle {"]
288292 lines += [f" request_header -{name}" for name in scrub]
289 lines += [f" reverse_proxy {auth} {{", " lb_try_duration 5s", " fail_duration 30s", " method GET", " rewrite " + ("/auth/file/check" if native else "/snow.oauth2/auth"),
293 lines += [f" reverse_proxy {auth} {{", " lb_try_duration 5s", *passive_health(auth, " "), " method GET", " rewrite " + ("/auth/file/check" if native else "/snow.oauth2/auth"),
290294 *([f" header_up Studio-Proxy-Token {dashboard_proof}"] if native else []),
291295 " header_up X-Forwarded-Method {method}", " header_up X-Forwarded-Uri {uri}",
292296 " @authenticated status 2xx", " handle_response @authenticated {"]