[master] 13015f599 For warmup/rampup, only consider healthy backends
Nils Goroll
nils.goroll at uplex.de
Tue Nov 6 10:17:13 UTC 2018
commit 13015f59968438afb5ac99a511dd654205089a30
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Tue Nov 6 10:56:44 2018 +0100
For warmup/rampup, only consider healthy backends
For healthy == IGNORE, we return before the call to shard_next(), so
at this point we do want to consider health state - and it makes
absolutely no sense to give up a healthy backend in favor of an un-
healthy one anyway.
Fixes #2823
diff --git a/bin/varnishtest/tests/d00023.vtc b/bin/varnishtest/tests/d00023.vtc
index 36ebe8e78..12c494f56 100644
--- a/bin/varnishtest/tests/d00023.vtc
+++ b/bin/varnishtest/tests/d00023.vtc
@@ -13,6 +13,9 @@ server s3 {
rxreq
expect req.http.healthy == "true"
txresp -body "xiuFi3Pe"
+ rxreq
+ expect req.http.healthy == "true"
+ txresp -body "xiuFi3Pe"
} -start
varnish v1 -vcl+backend {
@@ -29,8 +32,16 @@ varnish v1 -vcl+backend {
}
sub vcl_recv {
- set req.backend_hint = vd.backend(by=KEY,
- key=1756955383);
+ if (req.url == "/warmup") {
+ # key for which the order is s3->s1->s2
+ # we do not want to hit s1/s2 because they are down
+ set req.backend_hint = vd.backend(by=KEY,
+ key=192192123, warmup=1.0);
+ } else {
+ # key for which the order is s1->s2->s3
+ set req.backend_hint = vd.backend(by=KEY,
+ key=1756955383);
+ }
set req.http.healthy = std.healthy(req.backend_hint);
return(pass);
}
@@ -50,4 +61,7 @@ client c1 {
txreq
rxresp
expect resp.body == "xiuFi3Pe"
+ txreq -url "/warmup"
+ rxresp
+ expect resp.body == "xiuFi3Pe"
} -run
diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c
index bfc86f45a..acee05780 100644
--- a/lib/libvmod_directors/shard_dir.c
+++ b/lib/libvmod_directors/shard_dir.c
@@ -401,7 +401,7 @@ sharddir_pick_be(VRT_CTX, struct sharddir *shardd,
/* short path for cases we dont want ramup/warmup or can't */
if (alt > 0 || healthy == IGNORE || (!rampup && warmup == 0) ||
- shard_next(&state, 0, 0) == -1)
+ shard_next(&state, 0, 1) == -1)
goto ok;
assert(alt == 0);
More information about the varnish-commit
mailing list