]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Clarify how to return 'no server available' from the FFI policies
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 29 Mar 2024 14:57:19 +0000 (15:57 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 29 Mar 2024 14:57:19 +0000 (15:57 +0100)
pdns/dnsdistdist/docs/guides/serverselection.rst
pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc

index 1d9458621d4a2ba8dc6efaa513bc0606f44e80e0..25223f48a42cdaa98e1b0ea773335aaee1a79a94 100644 (file)
@@ -147,6 +147,10 @@ passing the name of a function:
     end
   ]])
 
+Note that this version, like the one above, returns the index (starting at 0) of the server to select.
+It was initially not possible to indicate that all servers were unavailable from these policies, but
+since 1.9.2 returning a value equal or greater than the number of servers will be interpreted as such.
+
 ServerPolicy Objects
 --------------------
 
index 8b6209f2bbe73325de7cb245874d040d113e00a7..07d67e2874b0f48fe6aa76f1b2f3c0a33cad4ba5 100644 (file)
@@ -655,7 +655,7 @@ BOOST_AUTO_TEST_CASE(test_lua_ffi_rr) {
 }
 
 BOOST_AUTO_TEST_CASE(test_lua_ffi_no_server_available) {
-  DNSName name("powerdns.com.");
+  DNSName dnsName("powerdns.com.");
   static const std::string policySetupStr = R"foo(
     local ffi = require("ffi")
     local C = ffi.C
@@ -670,8 +670,8 @@ BOOST_AUTO_TEST_CASE(test_lua_ffi_no_server_available) {
   )foo";
   resetLuaContext();
   g_lua.lock()->executeCode(getLuaFFIWrappers());
-  g_lua.lock()->writeFunction("setServerPolicyLuaFFI", [](string name, ServerPolicy::ffipolicyfunc_t policy) {
-      g_policy.setState(ServerPolicy(name, policy));
+  g_lua.lock()->writeFunction("setServerPolicyLuaFFI", [](string policyName, ServerPolicy::ffipolicyfunc_t policy) {
+      g_policy.setState(ServerPolicy(policyName, policy));
     });
   g_lua.lock()->executeCode(policySetupStr);
 
@@ -684,7 +684,7 @@ BOOST_AUTO_TEST_CASE(test_lua_ffi_no_server_available) {
     }
     BOOST_REQUIRE_EQUAL(servers.size(), 10U);
 
-    auto dq = getDQ(&name);
+    auto dq = getDQ(&dnsName);
     auto server = pol.getSelectedBackend(servers, dq);
     BOOST_REQUIRE(server == nullptr);
   }