]> git.kaiwu.me - haproxy.git/commitdiff
REGTESTS: proxy: test the disable-l7-retry action
authorWilly Tarreau <w@1wt.eu>
Tue, 22 Sep 2026 19:46:38 +0000 (19:46 +0000)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 15:25:37 +0000 (17:25 +0200)
The action had no coverage, and the notes listed adding a fourth
backend here as the way to get it. That backend is a copy of the one
which retries on a 503, with "disable-l7-retry" in an http-request
rule: the 503 of the first server must then reach the client as it is,
with txn.conn_retries left at zero, and the second server must not be
contacted at all.

reg-tests/proxy/retry_on.vtc

index b035e92f41ec88ed36aab446fbe6880ccaebe6e8..bd8b1021d3a9afeea8a78880dca7ed148f568f16 100644 (file)
@@ -4,10 +4,11 @@ varnishtest "Test the connection retries, retry-on and option redispatch"
 # txn.conn_retries and txn.redispatched fetches which report their
 # effect were not covered either.
 #
-# Three backends are used: one whose only server is unreachable, one
+# Four backends are used: one whose only server is unreachable, one
 # which redispatches to a healthy server after the first attempt fails,
-# and one which retries at the HTTP layer when the server answers with a
-# 503.
+# one which retries at the HTTP layer when the server answers with a
+# 503, and a copy of the latter where the "disable-l7-retry" action
+# cancels that retry.
 
 feature ignore_unknown_macro
 
@@ -26,6 +27,11 @@ server s3 {
        txresp -hdr "x-second: yes"
 } -start
 
+server s4 {
+       rxreq
+       txresp -status 503
+} -start
+
 haproxy h1 -conf {
     global
     .if feature(THREAD)
@@ -43,6 +49,7 @@ haproxy h1 -conf {
        bind "fd@${fe}"
        use_backend redisp if { path /redisp }
        use_backend l7     if { path /l7 }
+       use_backend nol7   if { path /nol7 }
        default_backend dead
 
        http-after-response set-header x-retries "%[txn.conn_retries]"
@@ -74,6 +81,17 @@ haproxy h1 -conf {
        option redispatch
        server bad ${s2_addr}:${s2_port}
        server good ${s3_addr}:${s3_port}
+
+    # same, but an http-request rule disables the L7 retry, so the 503 is
+    # delivered as it is and the second server is never contacted
+    backend nol7
+       balance first
+       retries 1
+       retry-on 503
+       option redispatch
+       http-request disable-l7-retry
+       server bad ${s4_addr}:${s4_port}
+       server good ${s3_addr}:${s3_port}
 } -start
 
 client c1 -connect ${h1_fe_sock} {
@@ -104,3 +122,13 @@ client c3 -connect ${h1_fe_sock} {
        expect resp.http.x-retries == "1"
        expect resp.http.x-redisp  == "1"
 } -run
+
+client c4 -connect ${h1_fe_sock} {
+       # "disable-l7-retry" leaves the 503 of the first server untouched
+       txreq -url "/nol7"
+       rxresp
+       expect resp.status == 503
+       expect resp.http.x-second  == "<undef>"
+       expect resp.http.x-retries == "0"
+       expect resp.http.x-redisp  == "0"
+} -run