[master] cab53eb33 shard: fix associated parameter set with resolve=NOW
Nils Goroll
nils.goroll at uplex.de
Thu Nov 12 16:31:11 UTC 2020
commit cab53eb33b267a96161a00abd0d26416a2a3a9bc
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Nov 12 16:45:40 2020 +0100
shard: fix associated parameter set with resolve=NOW
When a parameter set is associated at the director level, it should be
in effect with resolve=NOW as with resolve=LAZY.
diff --git a/bin/varnishtest/tests/d00021.vtc b/bin/varnishtest/tests/d00021.vtc
index e691def28..cf0a1be27 100644
--- a/bin/varnishtest/tests/d00021.vtc
+++ b/bin/varnishtest/tests/d00021.vtc
@@ -97,8 +97,9 @@ varnish v1 -vcl+backend {
}
sub vcl_backend_response {
- if (bereq.http.layered) {
+ if (bereq.http.layered || bereq.http.resolve) {
set beresp.http.healthy = std.healthy(ll.backend());
+ set beresp.http.backend-now = l.backend(resolve=NOW);
} else {
set beresp.http.healthy = std.healthy(
vd.backend(resolve=LAZY, by=KEY, key=1));
@@ -137,6 +138,7 @@ client c1 {
expect resp.http.healthy == "true"
expect resp.http.director == "ll"
expect resp.http.backend == "s1"
+ expect resp.http.backend == resp.http.backend-now
txreq -url /2 -hdr "layered: true"
rxresp
@@ -144,6 +146,7 @@ client c1 {
expect resp.http.healthy == "true"
expect resp.http.director == "ll"
expect resp.http.backend == "s2"
+ expect resp.http.backend == resp.http.backend-now
txreq -url /3 -hdr "layered: true"
rxresp
@@ -151,6 +154,7 @@ client c1 {
expect resp.http.healthy == "true"
expect resp.http.director == "ll"
expect resp.http.backend == "s3"
+ expect resp.http.backend == resp.http.backend-now
txreq -url /1 -hdr "resolve: true"
rxresp
@@ -158,6 +162,7 @@ client c1 {
expect resp.http.healthy == "true"
expect resp.http.director == "s1"
expect resp.http.backend == "s1"
+ expect resp.http.backend == resp.http.backend-now
txreq -url /2 -hdr "resolve: true"
rxresp
@@ -165,6 +170,7 @@ client c1 {
expect resp.http.healthy == "true"
expect resp.http.director == "s2"
expect resp.http.backend == "s2"
+ expect resp.http.backend == resp.http.backend-now
txreq -url /3 -hdr "resolve: true"
rxresp
@@ -172,4 +178,5 @@ client c1 {
expect resp.http.healthy == "true"
expect resp.http.director == "s3"
expect resp.http.backend == "s3"
+ expect resp.http.backend == resp.http.backend-now
} -run
diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c
index 5e0137bbc..a88095c26 100644
--- a/lib/libvmod_directors/vmod_shard.c
+++ b/lib/libvmod_directors/vmod_shard.c
@@ -608,6 +608,14 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard,
else
resolve = VENUM(NOW);
+ if (ctx->method & SHARD_VCL_TASK_BEREQ) {
+ pp = shard_param_task(ctx, vshard->shardd,
+ vshard->shardd->param);
+ if (pp == NULL)
+ return (NULL);
+ pp->vcl_name = vshard->shardd->name;
+ }
+
if (resolve == VENUM(LAZY)) {
if ((args & ~arg_resolve) == 0) {
AN(vshard->dir);
@@ -621,14 +629,6 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard,
"context");
return (NULL);
}
-
- assert(ctx->method & SHARD_VCL_TASK_BEREQ);
-
- pp = shard_param_task(ctx, vshard->shardd,
- vshard->shardd->param);
- if (pp == NULL)
- return (NULL);
- pp->vcl_name = vshard->shardd->name;
} else if (resolve == VENUM(NOW)) {
if (ctx->method & VCL_MET_TASK_H) {
shard_fail(ctx, vshard->shardd->name, "%s",
@@ -636,8 +636,9 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard,
"used in vcl_init{}/vcl_fini{}");
return (NULL);
}
- pp = shard_param_stack(&pstk, vshard->shardd->param,
- vshard->shardd->name);
+ pp = shard_param_stack(&pstk,
+ pp != NULL ? pp : vshard->shardd->param,
+ vshard->shardd->name);
} else {
WRONG("resolve enum");
}
More information about the varnish-commit
mailing list