Skip to content

Commit

Permalink
For warmup/rampup, only consider healthy backends
Browse files Browse the repository at this point in the history
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 13015f5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions bin/varnishtest/tests/d00023.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
Expand All @@ -50,4 +61,7 @@ client c1 {
txreq
rxresp
expect resp.body == "xiuFi3Pe"
txreq -url "/warmup"
rxresp
expect resp.body == "xiuFi3Pe"
} -run
2 changes: 1 addition & 1 deletion lib/libvmod_directors/shard_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 13015f5

Please sign in to comment.