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.
parent ad7ab013
...@@ -97,8 +97,9 @@ varnish v1 -vcl+backend { ...@@ -97,8 +97,9 @@ varnish v1 -vcl+backend {
} }
sub vcl_backend_response { 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.healthy = std.healthy(ll.backend());
set beresp.http.backend-now = l.backend(resolve=NOW);
} else { } else {
set beresp.http.healthy = std.healthy( set beresp.http.healthy = std.healthy(
vd.backend(resolve=LAZY, by=KEY, key=1)); vd.backend(resolve=LAZY, by=KEY, key=1));
...@@ -137,6 +138,7 @@ client c1 { ...@@ -137,6 +138,7 @@ client c1 {
expect resp.http.healthy == "true" expect resp.http.healthy == "true"
expect resp.http.director == "ll" expect resp.http.director == "ll"
expect resp.http.backend == "s1" expect resp.http.backend == "s1"
expect resp.http.backend == resp.http.backend-now
txreq -url /2 -hdr "layered: true" txreq -url /2 -hdr "layered: true"
rxresp rxresp
...@@ -144,6 +146,7 @@ client c1 { ...@@ -144,6 +146,7 @@ client c1 {
expect resp.http.healthy == "true" expect resp.http.healthy == "true"
expect resp.http.director == "ll" expect resp.http.director == "ll"
expect resp.http.backend == "s2" expect resp.http.backend == "s2"
expect resp.http.backend == resp.http.backend-now
txreq -url /3 -hdr "layered: true" txreq -url /3 -hdr "layered: true"
rxresp rxresp
...@@ -151,6 +154,7 @@ client c1 { ...@@ -151,6 +154,7 @@ client c1 {
expect resp.http.healthy == "true" expect resp.http.healthy == "true"
expect resp.http.director == "ll" expect resp.http.director == "ll"
expect resp.http.backend == "s3" expect resp.http.backend == "s3"
expect resp.http.backend == resp.http.backend-now
txreq -url /1 -hdr "resolve: true" txreq -url /1 -hdr "resolve: true"
rxresp rxresp
...@@ -158,6 +162,7 @@ client c1 { ...@@ -158,6 +162,7 @@ client c1 {
expect resp.http.healthy == "true" expect resp.http.healthy == "true"
expect resp.http.director == "s1" expect resp.http.director == "s1"
expect resp.http.backend == "s1" expect resp.http.backend == "s1"
expect resp.http.backend == resp.http.backend-now
txreq -url /2 -hdr "resolve: true" txreq -url /2 -hdr "resolve: true"
rxresp rxresp
...@@ -165,6 +170,7 @@ client c1 { ...@@ -165,6 +170,7 @@ client c1 {
expect resp.http.healthy == "true" expect resp.http.healthy == "true"
expect resp.http.director == "s2" expect resp.http.director == "s2"
expect resp.http.backend == "s2" expect resp.http.backend == "s2"
expect resp.http.backend == resp.http.backend-now
txreq -url /3 -hdr "resolve: true" txreq -url /3 -hdr "resolve: true"
rxresp rxresp
...@@ -172,4 +178,5 @@ client c1 { ...@@ -172,4 +178,5 @@ client c1 {
expect resp.http.healthy == "true" expect resp.http.healthy == "true"
expect resp.http.director == "s3" expect resp.http.director == "s3"
expect resp.http.backend == "s3" expect resp.http.backend == "s3"
expect resp.http.backend == resp.http.backend-now
} -run } -run
...@@ -608,6 +608,14 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard, ...@@ -608,6 +608,14 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard,
else else
resolve = VENUM(NOW); 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 (resolve == VENUM(LAZY)) {
if ((args & ~arg_resolve) == 0) { if ((args & ~arg_resolve) == 0) {
AN(vshard->dir); AN(vshard->dir);
...@@ -621,14 +629,6 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard, ...@@ -621,14 +629,6 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard,
"context"); "context");
return (NULL); 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)) { } else if (resolve == VENUM(NOW)) {
if (ctx->method & VCL_MET_TASK_H) { if (ctx->method & VCL_MET_TASK_H) {
shard_fail(ctx, vshard->shardd->name, "%s", shard_fail(ctx, vshard->shardd->name, "%s",
...@@ -636,8 +636,9 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard, ...@@ -636,8 +636,9 @@ vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard,
"used in vcl_init{}/vcl_fini{}"); "used in vcl_init{}/vcl_fini{}");
return (NULL); return (NULL);
} }
pp = shard_param_stack(&pstk, vshard->shardd->param, pp = shard_param_stack(&pstk,
vshard->shardd->name); pp != NULL ? pp : vshard->shardd->param,
vshard->shardd->name);
} else { } else {
WRONG("resolve enum"); WRONG("resolve enum");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment