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;
+ }
}
}
dss->upStatus = newState;
dss->currentCheckFailures = 0;
+ dss->consecutiveSuccesfulChecks = 0;
if (g_snmpAgent && g_snmpTrapsEnabled) {
g_snmpAgent->sendBackendStatusChangeTrap(dss);
}
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};
.. 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::
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
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.