WIP: demo use of shard params
This PR is not intended for merge. Also, it is related to the "primary only" feature which will be changed.
This patch on the shard_by_key.golden
file shows how shard parameters can be used to simplify the code.
Note: This piece of vcl
sub vcl_recv {
unset req.http.VK8S-Shard-Primary-Only;
if (remote.ip !~ vk8s_cluster_acl
&& "" + vk8s_cluster.backend(resolve=NOW, by=KEY, key=vk8s_cluster.key(req.http.Host)) != server.identity) {
set req.http.VK8S-Shard-Primary-Only = "true";
set req.backend_hint = vk8s_cluster.backend(resolve=NOW, by=KEY, key=vk8s_cluster.key(req.http.Host));
return (pass);
}
can not use shard params due to the limitation documented here: https://varnish-cache.org/docs/trunk/reference/vmod_directors.html#directors-shard-param
Parameter sets can not be used in client context except for vcl_pipe {}.
The reason is that, if a parameter set on the client side was modified, one would rightly expect it to still be active on the backend side.
Yet there currently exists no way to copy over state from the client to the backend side. https://github.com/varnishcache/varnish-cache/pull/3454 has been opened to suggest such mechanism but did not make it in yet.
Long story short: parameter sets are useful and can simplify the code, but as of now they can only be used on the backend side (and in vcl_pipe, but that of not much use).