Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different behavior of varnishd -C in varnish 5 #2316

Closed
mookie- opened this issue Apr 20, 2017 · 8 comments
Closed

Different behavior of varnishd -C in varnish 5 #2316

mookie- opened this issue Apr 20, 2017 · 8 comments

Comments

@mookie-
Copy link

mookie- commented Apr 20, 2017

Expected Behavior

If I run varnishd -C -f /etc/varnish/varnish.vcl -a 127.0.0.1:80 [...] varnishd should ignored the other options except "-C -f"

Current Behavior

On varnishd <5 it works. On varnishd >5 I get Error: Could not get socket 127.0.0.1:80: Address already in use

Possible Solution

Make it like before or note it in the changes/upgrade documentation.

Steps to Reproduce (for bugs)

  1. Start varnishd with -a $ip:$port
  2. execute varnishd -C -f /etc/varnish/varnish.vcl -a $ip:$port
  3. get Error: Could not get socket $ip:$port: Address already in use

Context

varnishd -C -f $all_other_varnish_options is used as configuration check in (some/many) init scripts.
Did work at least for varnish 3 and 4.

Your Environment

@nigoroll
Copy link
Member

Ref #2141 #2217

@nigoroll
Copy link
Member

@bsdphk I'm tempted to leave this with you due to your work on #2141.At first sight I'd think we need to pull the VSS_resolver() call out of MAC_Arg()

@mookie-
Copy link
Author

mookie- commented Apr 20, 2017

Something to add. Probably not all other options should be ignored. If you e.g. specify vcl_path with varnishd -p vcl_path=[...] this option is needed for -C. It's probably enough to just ignore the -as.

@nigoroll
Copy link
Member

Thanks @mookie-. That should be clear and was already discussed. See the other issues I referenced.

@denisbr
Copy link

denisbr commented Aug 15, 2017

Is there any update on this? Will this be fixed in next release?

@dridi
Copy link
Member

dridi commented Aug 17, 2017

This is a more complex problem than it looks, I'll try to summarize it here:

Some of the symbols available in VCL depend on the varnishd command line. Currently only the storage.<name> variables named after -s options, and in the future possibly new symbols for the -a options.

Those options are needed on the varnishd -C command line, so that for example -s small=malloc gives you a proper storage.small symbol in VCL and the associated storage.small.* variables (see man vcl).

One possibility we discussed was to ignore the options, and even allow to omit them. The -C mode would assume any storage to be valid. The flip side is that typos like storage.smalll would pass unnoticed.

So the next solution would be to require the same command line, but in -C mode this option would need to be the very first one (like -x when used) and the other options would avoid side effects outside of the working directory (eg. binding sockets, creating storage files etc).

I believe this is what we are supposed to do, but at this point I don't know our progress. I may have missed further discussions during the holidays season but to my knowledge this hasn't been discussed in a while. Current master doesn't enforce -C to be the first parameter when used.

@denisbr
Copy link

denisbr commented Aug 17, 2017

After @dridi explained the nitty gritty details, we agreed that if varnishd -C still doesn't work if there is a running varnishd, when the release is cut, we'll just put the "configtest before restart" logic on ice for now. It's better to have packages with a working restart than insisting on keeping this logic around (when it doesn't really work).

@bsdphk
Copy link
Contributor

bsdphk commented Nov 1, 2017

I am going to kill this ticket, because what is being asked for is patently not possible in general and would lead to tons and tons of ugly workarounds.

It would for instance be easy to add "pretend" code to -a arguments, but it would be wrong, because only by binding the socket do we actually get its IP and port number in the weird corner cases of FreeBSD-jails or :0

-C is for test-compiling VCL code (and seeing the resulting C source) it is not a flag for testing the rest of the arguments.

@bsdphk bsdphk closed this as completed Nov 1, 2017
denisbr pushed a commit to varnishcache/pkg-varnish-cache that referenced this issue Nov 6, 2017
Due to varnishcache/varnish-cache#2316
we cannot reliably config-test the VCL in the init-script.
If users want to configtest the VCL in advance of a restart, this
can be done with loading the new VCL into the running varnish, or
running ``varnishd -C`` with a different option-set that will not
conflict with the running instance(s).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants