Roadblock for Varnish 4 vmod_saintmode

Dag Haavi Finstad daghf at
Thu May 22 16:36:31 CEST 2014

Hi all,

I was about to do saintmode in a VMOD for 4.0. My idea was to
implement saintmode as a director, that lets you decorate a backend
(or director) with saintmode capabilities. The vdi_healthy function
for the saintmode director will then evaluate whether the backend is
healthy based on the current object in question, just like saintmode
in 3.0.

In VCL, a typical usage example

sub vcl_init {
    # first param is a backend, second param is saintmode_threshold
    new sm0 = saintmode.saintmode(b0, 10);
    new sm1 = saintmode.saintmode(b1, 10);

    new rr = directors.round_robin();

sub vcl_backend_fetch {
    set bereq.backend = rr.backend();

sub vcl_backend_response {
    if (beresp.status == 500) {
        return (retry);

In doing this, I ran into some problems when implementing the
vdi_healthy function. This function is of course invoked outside of
the typical VCL/vmod scope, thus we don't have the vrt_ctx
available. This makes it hard to do a saintmode vmod, when there is no
reliable way to get access to the objhead digest - which is very much
needed to see if this object is present on the trouble list.

In 3.0 this was solved by vdi_healthy getting a struct sess passed

  typedef unsigned vdi_healthy(const struct director *, const struct sess *sp);

compared with what we have currently,

  typedef unsigned vdi_healthy(const struct director *, double *changed);

I would like to discuss the possibility of adding a vrt_ctx parameter
(or simply the digest) to the vdi_healthy function in Varnish
4.0. Other suggestions would also be welcome. :)

I can probably suggest a patch for re-introducing a digest parameter,
if wanted.


Dag Haavi Finstad
Software Developer | Varnish Software AS
Mobile: +47 476 64 134
We Make Websites Fly!

More information about the varnish-dev mailing list