[Varnish] #846: Let varnishd continue running when encountering unused backends in a configuration

Varnish varnish-bugs at varnish-cache.org
Fri Jan 14 10:56:28 CET 2011


#846: Let varnishd continue running when encountering unused backends in a
configuration
-------------------------------------+--------------------------------------
 Reporter:  jhalfmoon                |        Type:  enhancement
   Status:  new                      |    Priority:  normal     
Milestone:                           |   Component:  varnishd   
  Version:  2.1.4                    |    Severity:  normal     
 Keywords:  unused backend exit vcl  |  
-------------------------------------+--------------------------------------
 Varnishd (we're currently using 2.1.4) exits when encountering unused
 backends in a configuration. It throws an errror and exits like so:

 Message from VCC-compiler:
 Warning: Unused backend www_testsite_com, defined:
 (/etc/varnish/sites/testsite_com Line 3 Pos 9)
 backend www_testsite_com { .host = "1.2.3.4"; }
 --------####################---------------------------------------------------------------------
 Running VCC-compiler failed, exit 1
 VCL compilation failed

 It would be nice if Varnishd had an option like '--continue-on-warning'
 that makes Varnish continue running when encountering a non fatal
 situation like the one above.

 The reason this feature is desirable is because we are running a VCL with
 lots of inline C code and among other things, the backends get checked and
 set in this C code. So in fact, there are no unused backends in our VCL,
 but Varnish just does not see us using them. We currently use the
 following code to work around this problem by creating a dummy-reference
 to the backends, but it makes the VCLs really messy, and we have a lot of
 backends. Here's the workaround:

 sub vcl_error {
      # the code within the if-block never gets executed
      if (req.http.host ~ "^kludge$") {
          set req.backend = www_testsite_com ;
          set req.backend = etc..etc...etc...
      }

 As far as I can see, a fix for this issue is very unintrusive, but then
 again I don't have the overview of the fulltime developpers. I can do a
 quick and dirty fix of the problem by preventing Varnish from exiting on
 an 'Unused object' error, using the following patch:

 diff --git a/lib/libvcl/vcc_xref.c b/lib/libvcl/vcc_xref.c
 index c9b0418..9c5547b 100644
 --- a/lib/libvcl/vcc_xref.c
 +++ b/lib/libvcl/vcc_xref.c
 @@ -168,9 +168,11 @@ vcc_CheckReferences(struct tokenlist *tl)
                         continue;
                 }

 -               vsb_printf(tl->sb, "Unused %s %.*s, defined:\n",
 +               vsb_printf(tl->sb, "Warning: Unused %s %.*s, defined:\n",
                     type, PF(r->name));
                 vcc_ErrWhere(tl, r->name);
 +        tl->err=0;                  // Patch: This unsets the errorcode
 that was set by vcc_ErrWhere
 +        nerr=0;                     // Patch: This unsets the errorcode
 set by the above 'nerr++'
         }
         return (nerr);
  }

 But I'd rather be using vanilla Varnishd sourcecode for our production
 machines. Thanks for your time and I hope this helps.

-- 
Ticket URL: <http://www.varnish-cache.org/trac/ticket/846>
Varnish <http://varnish-cache.org/>
The Varnish HTTP Accelerator




More information about the varnish-bugs mailing list