Permalink
Browse files

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
  • Loading branch information...
nigoroll committed Nov 6, 2018
1 parent cd17821 commit 13015f59968438afb5ac99a511dd654205089a30
Showing with 17 additions and 3 deletions.
  1. +16 −2 bin/varnishtest/tests/d00023.vtc
  2. +1 −1 lib/libvmod_directors/shard_dir.c
@@ -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
@@ -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);

0 comments on commit 13015f5

Please sign in to comment.