[master] 0773342 (struct director).admin_health needs initialization
Nils Goroll
nils.goroll at uplex.de
Thu Jan 11 13:33:05 UTC 2018
commit 0773342679f5cf4e696162ce1e20069d2a3c84b6
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Jan 11 14:14:46 2018 +0100
(struct director).admin_health needs initialization
... otherwise we will hit the WRONG("Wrong admin health") in VDI_Healthy()
for std.healthy().
Ref: https://github.com/nigoroll/varnish-modules/issues/5
diff --git a/bin/varnishtest/tests/d00000.vtc b/bin/varnishtest/tests/d00000.vtc
index 507e9c7..3ca3528 100644
--- a/bin/varnishtest/tests/d00000.vtc
+++ b/bin/varnishtest/tests/d00000.vtc
@@ -22,6 +22,7 @@ server s4 {
varnish v1 -vcl+backend {
import directors;
+ import std;
sub vcl_init {
new rr = directors.round_robin();
@@ -40,6 +41,10 @@ varnish v1 -vcl+backend {
}
}
+ sub vcl_deliver {
+ set resp.http.healthy = std.healthy(rr.backend());
+ }
+
sub vcl_backend_fetch {
set bereq.backend = rr.backend();
}
@@ -50,15 +55,19 @@ client c1 {
txreq -url "/foo1"
rxresp
expect resp.bodylen == 1
+ expect resp.http.healthy == "true"
txreq -url "/foo2"
rxresp
expect resp.bodylen == 2
+ expect resp.http.healthy == "true"
txreq -url "/foo3"
rxresp
expect resp.bodylen == 3
+ expect resp.http.healthy == "true"
txreq -url "/foo4"
rxresp
expect resp.bodylen == 4
+ expect resp.http.healthy == "true"
} -run
server s1 -start
@@ -69,9 +78,11 @@ client c2 {
txreq -url "/foo11"
rxresp
expect resp.bodylen == 1
+ expect resp.http.healthy == "true"
txreq -url "/foo22"
rxresp
expect resp.bodylen == 2
+ expect resp.http.healthy == "true"
} -run
server s4 -start
@@ -83,4 +94,5 @@ client c3 {
txreq -url "/foo31"
rxresp
expect resp.bodylen == 4
+ expect resp.http.healthy == "true"
} -run
diff --git a/doc/changes.rst b/doc/changes.rst
index b09221b..cb9fe31 100644
--- a/doc/changes.rst
+++ b/doc/changes.rst
@@ -104,6 +104,11 @@ C APIs (for vmod and utility authors)
* Added ``VRT_blob()`` utility function to create a blob as a copy
of some chunk of data on the workspace.
+* Directors now have their own admin health information and always need to
+ have the ``(struct director).admin_health`` initialized to
+ ``VDI_AH_*`` (usually ``VDI_AH_HEALTHY``).
+
+ XXX improve / more details
Other changes relevant for VMODs
--------------------------------
diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c
index a334635..6a06412 100644
--- a/lib/libvmod_directors/vdir.c
+++ b/lib/libvmod_directors/vdir.c
@@ -71,6 +71,7 @@ vdir_new(struct vdir **vdp, const char *name, const char *vcl_name,
vd->dir->priv = priv;
vd->dir->healthy = healthy;
vd->dir->resolve = resolve;
+ vd->dir->admin_health = VDI_AH_HEALTHY;
vd->vbm = vbit_new(8);
AN(vd->vbm);
}
More information about the varnish-commit
mailing list