]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Add a 'rise' parameter to 'newServer()' 7322/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 3 Jan 2019 15:14:28 +0000 (16:14 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 10 Jan 2019 15:21:48 +0000 (16:21 +0100)
pdns/dnsdist-lua.cc
pdns/dnsdist.cc
pdns/dnsdist.hh
pdns/dnsdistdist/docs/reference/config.rst

index 091e8e50555f24897276e33542f86381c8996d90..49bdde30e4a987fbcd39ad9348df2e760ba6d6a8 100644 (file)
@@ -368,6 +368,10 @@ void setupLuaConfig(bool client)
                          ret->maxCheckFailures=std::stoi(boost::get<string>(vars["maxCheckFailures"]));
                        }
 
+                        if(vars.count("rise")) {
+                          ret->minRiseSuccesses=std::stoi(boost::get<string>(vars["rise"]));
+                        }
+
                         if(vars.count("cpus")) {
                           for (const auto cpu : boost::get<vector<pair<int,string>>>(vars["cpus"])) {
                             cpus.insert(std::stoi(cpu.second));
index a6c4e7accbc0751173e3be6df55b7a818bc8af0e..aafe16ac9d1a406723a8142d1aa4792130c57e62 100644 (file)
@@ -1930,14 +1930,32 @@ static void healthChecksThread()
       if(dss->availability==DownstreamState::Availability::Auto) {
         bool newState=upCheck(*dss);
         if (newState) {
-          if (dss->currentCheckFailures != 0) {
-            dss->currentCheckFailures = 0;
+          /* check succeeded */
+          dss->currentCheckFailures = 0;
+
+          if (!dss->upStatus) {
+            /* we were marked as down */
+            dss->consecutiveSuccesfulChecks++;
+            if (dss->consecutiveSuccesfulChecks < dss->minRiseSuccesses) {
+              /* if we need more than one successful check to rise
+                 and we didn't reach the threshold yet,
+                 let's stay down */
+              newState = false;
+            }
           }
         }
-        else if (!newState && dss->upStatus) {
-          dss->currentCheckFailures++;
-          if (dss->currentCheckFailures < dss->maxCheckFailures) {
-            newState = true;
+        else {
+          /* check failed */
+          dss->consecutiveSuccesfulChecks = 0;
+
+          if (dss->upStatus) {
+            /* we are currently up */
+            dss->currentCheckFailures++;
+            if (dss->currentCheckFailures < dss->maxCheckFailures) {
+              /* we need more than one failure to be marked as down,
+                 and we did not reach the threshold yet, let's stay down */
+              newState = true;
+            }
           }
         }
 
@@ -1954,6 +1972,7 @@ static void healthChecksThread()
 
           dss->upStatus = newState;
           dss->currentCheckFailures = 0;
+          dss->consecutiveSuccesfulChecks = 0;
           if (g_snmpAgent && g_snmpTrapsEnabled) {
             g_snmpAgent->sendBackendStatusChangeTrap(dss);
           }
index bbeeb0bcba60ad59bacac72e93cd91fe5686f49a..0827bcdba38373cd46d448d7f4fd1a608ac57158 100644 (file)
@@ -711,7 +711,9 @@ struct DownstreamState
   uint16_t xpfRRCode{0};
   uint16_t checkTimeout{1000}; /* in milliseconds */
   uint8_t currentCheckFailures{0};
+  uint8_t consecutiveSuccesfulChecks{0};
   uint8_t maxCheckFailures{1};
+  uint8_t minRiseSuccesses{1};
   StopWatch sw;
   set<string> pools;
   enum class Availability { Up, Down, Auto} availability{Availability::Auto};
index 6015f7808a5ccc45f7da3dc9bdbd1c80c034b2ca..193dda46bfcfe513c901ff481f1343929d2d1418 100644 (file)
@@ -312,6 +312,7 @@ Servers
 
   .. versionchanged:: 1.3.4
     - Added ``checkTimeout`` to server_table
+    - Added ``rise`` to server_table.
 
   Add a new backend server. Call this function with either a string::
 
@@ -339,8 +340,8 @@ Servers
       checkClass=NUM,        -- Use NUM as QCLASS in the health-check query, default: DNSClass.IN
       checkName=STRING,      -- Use STRING as QNAME in the health-check query, default: "a.root-servers.net."
       checkType=STRING,      -- Use STRING as QTYPE in the health-check query, default: "A"
-      checkFunction=FUNCTION -- Use this function to dynamically set the QNAME, QTYPE and QCLASS to use in the health-check query (see :ref:`Healthcheck`)
-      checkTimeout=NUM       -- The timeout (in milliseconds) of a health-check query, default: 1000 (1s)
+      checkFunction=FUNCTION,-- Use this function to dynamically set the QNAME, QTYPE and QCLASS to use in the health-check query (see :ref:`Healthcheck`)
+      checkTimeout=NUM,      -- The timeout (in milliseconds) of a health-check query, default: 1000 (1s)
       setCD=BOOL,            -- Set the CD (Checking Disabled) flag in the health-check query, default: false
       maxCheckFailures=NUM,  -- Allow NUM check failures before declaring the backend down, default: 1
       mustResolve=BOOL,      -- Set to true when the health check MUST return a NOERROR RCODE and an answer
@@ -353,7 +354,8 @@ Servers
       addXPF=NUM,            -- Add the client's IP address and port to the query, along with the original destination address and port,
                              -- using the experimental XPF record from `draft-bellis-dnsop-xpf <https://datatracker.ietf.org/doc/draft-bellis-dnsop-xpf/>`_ and the specified option code. Default is disabled (0)
       sockets=NUM,           -- Number of sockets (and thus source ports) used toward the backend server, defaults to a single one
-      disableZeroScope       -- Disable the EDNS Client Subnet 'zero scope' feature, which does a cache lookup for an answer valid for all subnets (ECS scope of 0) before adding ECS information to the query and doing the regular lookup
+      disableZeroScope=BOOL, -- Disable the EDNS Client Subnet 'zero scope' feature, which does a cache lookup for an answer valid for all subnets (ECS scope of 0) before adding ECS information to the query and doing the regular lookup
+      rise=NUM               -- Require NUM consecutive successful checks before declaring the backend up, default: 1
     })
 
   :param str server_string: A simple IP:PORT string.