MEDIUM: filters: eval the backend instances first on the response path · haproxy/haproxy@4ac7c48 · GitHub
Skip to content

Commit 4ac7c48

Browse files
committed
MEDIUM: filters: eval the backend instances first on the response path
When the backend filters are attached to a stream, they are appended to the global and request filter lists after the frontend ones, which is the expected order: the request reaches the frontend filters first. But they were also appended to the response filter list, while a response travels in the opposite direction and reaches the backend filters first. In the new filter mode, the backend instances are now prepended to the response filter list, preserving their own response order, so a response is evaluated by the backend instances before the frontend ones. The request path is unchanged. The regression tests relying on the response evaluation order of the instance mode were updated accordingly.
1 parent 6180839 commit 4ac7c48

7 files changed

Lines changed: 56 additions & 37 deletions

File tree

‎reg-tests/filters/lua-defaults.vtc‎

Lines changed: 2 additions & 2 deletions

‎reg-tests/filters/lua-keepalive.vtc‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ client c1 -connect ${h1_fe_sock} {
9797
txreq -req POST -url /instances -body "first"
9898
rxresp
9999
expect resp.status == 200
100-
expect resp.http.x-probe-order == "F.b;F.a;D.c;D.a;"
101-
expect resp.http.x-probe-instances == "F.b:1;F.a:2;D.c:1;D.a:2;"
102-
expect resp.http.x-probe-request-bytes == "F.a:5;D.c:5;"
100+
expect resp.http.x-probe-order == "D.c;D.a;F.b;F.a;"
101+
expect resp.http.x-probe-instances == "D.c:1;D.a:2;F.b:1;F.a:2;"
102+
expect resp.http.x-probe-request-bytes == "D.c:5;F.a:5;"
103103
expect resp.http.x-probe-errors == <undef>
104104
expect resp.body == "first response"
105105

@@ -127,9 +127,9 @@ client c1 -connect ${h1_fe_sock} {
127127
txreq -req POST -url /instances -body "fourth"
128128
rxresp
129129
expect resp.status == 200
130-
expect resp.http.x-probe-order == "F.b;F.a;D.c;D.a;"
131-
expect resp.http.x-probe-instances == "F.b:7;F.a:8;D.c:3;D.a:4;"
132-
expect resp.http.x-probe-request-bytes == "F.a:6;D.c:6;"
130+
expect resp.http.x-probe-order == "D.c;D.a;F.b;F.a;"
131+
expect resp.http.x-probe-instances == "D.c:3;D.a:4;F.b:7;F.a:8;"
132+
expect resp.http.x-probe-request-bytes == "D.c:6;F.a:6;"
133133
expect resp.http.x-probe-errors == <undef>
134134
expect resp.body == "fourth response"
135135
} -run
@@ -138,8 +138,8 @@ client c2 -connect ${h1_fe_sock} {
138138
txreq -req POST -url /instances -body "new"
139139
rxresp
140140
expect resp.status == 200
141-
expect resp.http.x-probe-instances == "F.b:9;F.a:10;D.c:5;D.a:6;"
142-
expect resp.http.x-probe-request-bytes == "F.a:3;D.c:3;"
141+
expect resp.http.x-probe-instances == "D.c:5;D.a:6;F.b:9;F.a:10;"
142+
expect resp.http.x-probe-request-bytes == "D.c:3;F.a:3;"
143143
expect resp.http.x-probe-errors == <undef>
144144
expect resp.body == "new connection"
145145
} -run

‎reg-tests/filters/lua-per-thread.vtc‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ client c1 -connect ${h1_one_sock} {
7272
txreq
7373
rxresp
7474
expect resp.status == 200
75-
expect resp.http.x-probe-order == "F.b;F.a;B.c;B.a;"
76-
expect resp.http.x-probe-threads == "F.b:1;F.a:1;B.c:1;B.a:1;"
77-
expect resp.http.x-probe-instances == "F.b:1;F.a:2;B.c:2;B.a:1;"
75+
expect resp.http.x-probe-order == "B.c;B.a;F.b;F.a;"
76+
expect resp.http.x-probe-threads == "B.c:1;B.a:1;F.b:1;F.a:1;"
77+
expect resp.http.x-probe-instances == "B.c:2;B.a:1;F.b:1;F.a:2;"
7878
expect resp.http.x-probe-errors == <undef>
7979
expect resp.body == "thread one"
8080
} -run
@@ -83,9 +83,9 @@ client c2 -connect ${h1_two_sock} {
8383
txreq
8484
rxresp
8585
expect resp.status == 200
86-
expect resp.http.x-probe-order == "F.b;F.a;B.c;B.a;"
87-
expect resp.http.x-probe-threads == "F.b:2;F.a:2;B.c:2;B.a:2;"
88-
expect resp.http.x-probe-instances == "F.b:1;F.a:2;B.c:2;B.a:1;"
86+
expect resp.http.x-probe-order == "B.c;B.a;F.b;F.a;"
87+
expect resp.http.x-probe-threads == "B.c:2;B.a:2;F.b:2;F.a:2;"
88+
expect resp.http.x-probe-instances == "B.c:2;B.a:1;F.b:1;F.a:2;"
8989
expect resp.http.x-probe-errors == <undef>
9090
expect resp.body == "thread two"
9191
} -run
@@ -94,8 +94,8 @@ client c3 -connect ${h1_one_sock} {
9494
txreq
9595
rxresp
9696
expect resp.status == 200
97-
expect resp.http.x-probe-threads == "F.b:1;F.a:1;B.c:1;B.a:1;"
98-
expect resp.http.x-probe-instances == "F.b:3;F.a:4;B.c:4;B.a:3;"
97+
expect resp.http.x-probe-threads == "B.c:1;B.a:1;F.b:1;F.a:1;"
98+
expect resp.http.x-probe-instances == "B.c:4;B.a:3;F.b:3;F.a:4;"
9999
expect resp.http.x-probe-errors == <undef>
100100
expect resp.body == "thread one again"
101101
} -run
@@ -104,8 +104,8 @@ client c4 -connect ${h1_two_sock} {
104104
txreq
105105
rxresp
106106
expect resp.status == 200
107-
expect resp.http.x-probe-threads == "F.b:2;F.a:2;B.c:2;B.a:2;"
108-
expect resp.http.x-probe-instances == "F.b:3;F.a:4;B.c:4;B.a:3;"
107+
expect resp.http.x-probe-threads == "B.c:2;B.a:2;F.b:2;F.a:2;"
108+
expect resp.http.x-probe-instances == "B.c:4;B.a:3;F.b:3;F.a:4;"
109109
expect resp.http.x-probe-errors == <undef>
110110
expect resp.body == "thread two again"
111111
} -run

‎reg-tests/filters/lua-resume.vtc‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ client c1 -connect ${h1_fe_sock} {
6464
txreq -req POST -body "abcdefgh"
6565
rxresp
6666
expect resp.status == 200
67-
expect resp.http.x-probe-order == "F.c;F.a;F.b;B.a;B.c;B.b;"
68-
expect resp.http.x-probe-instances == "F.c:2;F.a:1;F.b:3;B.a:2;B.c:1;B.b:3;"
69-
expect resp.http.x-probe-request-bytes == "F.b:8;B.a:8;B.c:8;"
67+
expect resp.http.x-probe-order == "B.a;B.c;B.b;F.c;F.a;F.b;"
68+
expect resp.http.x-probe-instances == "B.a:2;B.c:1;B.b:3;F.c:2;F.a:1;F.b:3;"
69+
expect resp.http.x-probe-request-bytes == "B.a:8;B.c:8;F.b:8;"
7070
expect resp.http.x-probe-errors == <undef>
7171
expect resp.body == "response after waits"
7272

@@ -76,9 +76,9 @@ client c1 -connect ${h1_fe_sock} {
7676
chunked ""
7777
rxresp
7878
expect resp.status == 200
79-
expect resp.http.x-probe-order == "F.c;F.a;F.b;B.a;B.c;B.b;"
80-
expect resp.http.x-probe-instances == "F.c:5;F.a:4;F.b:6;B.a:5;B.c:4;B.b:6;"
81-
expect resp.http.x-probe-request-bytes == "F.b:8;B.a:8;B.c:8;"
79+
expect resp.http.x-probe-order == "B.a;B.c;B.b;F.c;F.a;F.b;"
80+
expect resp.http.x-probe-instances == "B.a:5;B.c:4;B.b:6;F.c:5;F.a:4;F.b:6;"
81+
expect resp.http.x-probe-request-bytes == "B.a:8;B.c:8;F.b:8;"
8282
expect resp.http.x-probe-errors == <undef>
8383
expect resp.body == "another response"
8484
barrier b_drained sync

‎reg-tests/filters/lua-retry.vtc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ client c1 -connect ${h1_fe_sock} {
6666
expect resp.status == 200
6767
expect resp.http.x-retries == "1"
6868
expect resp.http.x-redispatched == "1"
69-
expect resp.http.x-probe-order == "F.b;F.a;B.a;B.c;"
70-
expect resp.http.x-probe-instances == "F.b:1;F.a:2;B.a:2;B.c:1;"
69+
expect resp.http.x-probe-order == "B.a;B.c;F.b;F.a;"
70+
expect resp.http.x-probe-instances == "B.a:2;B.c:1;F.b:1;F.a:2;"
7171
expect resp.http.x-probe-errors == <undef>
7272
expect resp.body == "successful retry"
7373
barrier b_drained sync

‎reg-tests/filters/stream-order.vtc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ client c1 -connect ${h1_fe_sock} {
5858
txreq -req POST -body "ping"
5959
rxresp
6060
expect resp.status == 200
61-
expect resp.http.x-filter-order == "Fb:3;Fc:1;Fa:2;Ba:2;Bb:1;Bc:3;"
61+
expect resp.http.x-filter-order == "Ba:2;Bb:1;Bc:3;Fb:3;Fc:1;Fa:2;"
6262
expect resp.http.x-filter-start == <undef>
6363
expect resp.body == "pong"
6464
} -run
@@ -100,7 +100,7 @@ client c2 -connect ${h2_fe_sock} {
100100
txreq
101101
rxresp
102102
expect resp.status == 200
103-
expect resp.http.x-filter-order == "Fa:1;Fb:2;Ba:1;Bb:2;"
103+
expect resp.http.x-filter-order == "Ba:1;Bb:2;Fa:1;Fb:2;"
104104
expect resp.http.x-filter-start == <undef>
105105
} -run
106106

‎src/filters.c‎

Lines changed: 26 additions & 7 deletions

0 commit comments

Comments
 (0)