]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Document the new behaviour for custom LB policies written in Lua
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 6 Oct 2025 14:06:32 +0000 (16:06 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 6 Oct 2025 14:50:26 +0000 (16:50 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/docs/guides/serverselection.rst
pdns/dnsdistdist/docs/upgrade_guide.rst

index b562d78c063ab8b14679967aeb528c5395703e21..3b7d717d25354e515aa4ad6103dcbf02219253ae 100644 (file)
@@ -97,7 +97,11 @@ If all servers are down, the policy will still select one server by default. Set
 Lua server policies
 -------------------
 
-If you don't like the default policies you can create your own, like this for example::
+.. warning::
+
+  There has been a significant change to the way custom load-balancing policies written in Lua works since 2.1.0: they now need to return the index in the servers array of the backend they intend to select, instead of returning a reference the backend itself.
+
+If you don't like the default policies you can create your own, like this for example (before 2.1.0)::
 
   counter=0
   function luaroundrobin(servers, dq)
@@ -107,6 +111,16 @@ If you don't like the default policies you can create your own, like this for ex
 
   setServerPolicyLua("luaroundrobin", luaroundrobin)
 
+Since 2.1.0 this should instead be::
+
+  counter=0
+  function luaroundrobin(servers, dq)
+       counter=counter+1
+       return 1+(counter % #servers)
+  end
+
+  setServerPolicyLua("luaroundrobin", luaroundrobin)
+
 Incidentally, this is similar to setting: ``setServerPolicy(roundrobin)`` which uses the C++ based roundrobin policy.
 
 Or::
index b33aeeb69b37295f06322c582e552fbd3ae3f92a..020ca59f3c231dc95156870e5dfd7f0e32da62d1 100644 (file)
@@ -1,6 +1,11 @@
 Upgrade Guide
 =============
 
+2.0.x to 2.1.0
+--------------
+
+Custom load-balancing policies written in Lua now need to return the index in the servers array of the backend they intend to select, instead of returning a reference the backend itself.
+
 1.9.x to 2.0.0
 --------------