varnish / varnish-modules

Collection of Varnish Cache modules (vmods) by Varnish Software
Other
182 stars 86 forks source link

"failed to get task priv for vmod cookie" with Varnish 6.0.2 #132

Closed wcz-txp closed 5 years ago

wcz-txp commented 5 years ago

Hello,

I wanted to update Varnish from 6.0.0 to 6.0.2 and to use together with the last github version of the cookie module, which is activated by "import cookie;" in a "vcl 4.1;" configuration file.

Compiling both is without problem. Varnish is compiled like that: ./configure --prefix=/usr/local/varnish; make; make install

and the modules like that: export ACLOCAL_PATH=/usr/local/varnish/share/aclocal; export PKG_CONFIG_PATH=/usr/local/varnish/lib/pkgconfig; ./bootstrap; ./configure --prefix=/usr/local/varnish; make; make install

but testing the configuration by rc=$?; if [[ $rc != 1 ]]; then sudo /usr/local/varnish/sbin/varnishd -Cf /etc/varnish/varnish4.vcl | grep failed; else echo -e "OK (Exitcode: $rc)\n"; fi ends with this error message: VRT_fail(ctx, "failed to get task priv for vmod cookie") ...

dridi commented 5 years ago

I'll take on this one next week unless there are faster-than-me takers.

dridi commented 5 years ago

@wcz-txp can you please share a minimal VCL to reproduce this?

dridi commented 5 years ago

Ok, I was able to reproduce this with this VCL:

vcl 4.1;

import cookie;

backend be {
        .host = "localhost";
}

sub vcl_recv {
        cookie.parse("cookie1: value1; cookie2: value2;");
}

And then:

$ varnishd -Cf $PWD/test.vcl 2>&1 | grep failed
    VRT_fail(ctx, "failed to get task priv for vmod cookie");

But this is really not a problem:

$ varnishd -Cf $PWD/test.vcl 2>&1 | grep -C2 failed
  struct vmod_priv *ARG_priv_task_cookie = VRT_priv_task(ctx, &VGC_vmod_cookie);
  if (ARG_priv_task_cookie == NULL) {
    VRT_fail(ctx, "failed to get task priv for vmod cookie");
    return;
  }

This is part of the generated C code and this is not a regression. Instead of using grep failed you should instead check the exit status of varnishd -C to figure whether a VCL failed to compile.