From: Remi Gacogne Date: Fri, 29 Mar 2024 14:57:19 +0000 (+0100) Subject: dnsdist: Clarify how to return 'no server available' from the FFI policies X-Git-Tag: rec-5.1.0-alpha1~68^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=faa96abfe2b025d2322bebb60882e6c775855c11;p=thirdparty%2Fpdns.git dnsdist: Clarify how to return 'no server available' from the FFI policies --- diff --git a/pdns/dnsdistdist/docs/guides/serverselection.rst b/pdns/dnsdistdist/docs/guides/serverselection.rst index 1d9458621d..25223f48a4 100644 --- a/pdns/dnsdistdist/docs/guides/serverselection.rst +++ b/pdns/dnsdistdist/docs/guides/serverselection.rst @@ -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 -------------------- diff --git a/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc b/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc index 8b6209f2bb..07d67e2874 100644 --- a/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc @@ -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); }