2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-03 07:25:18 +00:00

[#1621] disabling connection recovery mechanish is not available in core managers

This commit is contained in:
Razvan Becheriu
2021-03-24 08:19:00 +02:00
parent a7cb38305f
commit f525fc6335
17 changed files with 62 additions and 144 deletions

View File

@@ -368,10 +368,7 @@
"max-reconnect-tries": 3,
// Disable DHCP on database connection loss.
"disable-dhcp-on-db-loss": true,
// Enable database connection recovery.
"enable-connection-recovery": true,
"disable-service-on-db-loss": true,
// Connection connect timeout.
"connect-timeout": 100,

View File

@@ -42,8 +42,7 @@
// "password": "secret1",
// "reconnect-wait-time": 3000, // expressed in ms
// "max-reconnect-tries": 3,
// "disable-dhcp-on-db-loss": true,
// "enable-connection-recovery": true,
// "disable-service-on-db-loss": true,
// "connect-timeout": 3
// },
@@ -63,8 +62,7 @@
// "password": "secret1",
// "reconnect-wait-time": 3000, // expressed in ms
// "max-reconnect-tries": 3,
// "disable-dhcp-on-db-loss": true,
// "enable-connection-recovery": true,
// "disable-service-on-db-loss": true,
// "connect-timeout": 3
// },

View File

@@ -310,10 +310,7 @@
"max-reconnect-tries": 3,
// Disable DHCP on database connection loss.
"disable-dhcp-on-db-loss": true,
// Enable database connection recovery.
"enable-connection-recovery": true,
"disable-service-on-db-loss": true,
// Connection connect timeout.
"connect-timeout": 100,

View File

@@ -42,8 +42,7 @@
// "password": "secret1",
// "reconnect-wait-time": 3000, // expressed in ms
// "max-reconnect-tries": 3,
// "disable-dhcp-on-db-loss": true,
// "enable-connection-recovery": true,
// "disable-service-on-db-loss": true,
// "connect-timeout": 3
// },
@@ -63,8 +62,7 @@
// "password": "secret1",
// "reconnect-wait-time": 3000, // expressed in ms
// "max-reconnect-tries": 3,
// "disable-dhcp-on-db-loss": true,
// "enable-connection-recovery": true,
// "disable-service-on-db-loss": true,
// "connect-timeout": 3
// },

View File

@@ -6,8 +6,8 @@ Database Connectivity
Kea servers (kea-dhcp4 and kea-dhcp6) can be configured to use a variety of
database backends for leases, hosts, and configuration. All of them may be
configured to support automatic recovery when connectivity is lost (see
``max-reconnect-tries``, ``reconnect-wait-time``, ``disable-dhcp-on-db-loss``
and ``enable-connection-recovery``).
``max-reconnect-tries``, ``reconnect-wait-time``and
``disable-service-on-db-loss``).
It is important to understand how and when automatic recovery comes into play.
Automatic recovery, when configured, only operates after a successful startup
@@ -29,15 +29,8 @@ allows the configuration to be corrected via command, if required.
During normal operations, if connectivity to any of the backends is lost and
automatic recovery for that backend is enabled, the server disconnects from the
respective backend and then attempts to reconnect. During the recovery process,
the server ceases to serve clients according to the ``disable-dhcp-on-db-loss``
configured option, and continues to respond to commands. If connectivity to all
backends is restored, the server returns to normal operations. If connectivity
cannot be restored after ``max-reconnect-tries``, the server issues a fatal
error and exits.
The entire database connection mechanism can be completely disabled by setting
``enable-connection-recovery`` to false. This will cause the server to ignore
the failure of the database connections and it is highly discouraged. This will
cause the server to not function properly and log errors. The default value for
``enable-connection-recovery`` is true. This feature is mainly used by hook
libraries which can function properly without permanent database connections.
the server ceases to serve clients according to the
``disable-service-on-db-loss`` configured option, and continues to respond to
commands. If connectivity to all backends is restored, the server returns to
normal operations. If connectivity cannot be restored after
``max-reconnect-tries``, the server issues a fatal error and exits.

View File

@@ -506,18 +506,11 @@ loss of connectivity. The default value for Cassandra is 2000 ms.
::
"Dhcp4": { "lease-database": { "disable-dhcp-on-db-loss" : true, ... }, ... }
"Dhcp4": { "lease-database": { "disable-service-on-db-loss" : true, ... }, ... }
The default value for MySQL and PostgreSQL is true, which disables the dhcp
service while trying to automatically recover lost connections.
::
"Dhcp4": { "lease-database": { "enable-connection-recovery" : true, ... }, ... }
The default value for MySQL and PostgreSQL is true, which enables the server to
automatically recover lost connections.
.. note::
Automatic reconnection to database backends is configured
@@ -732,18 +725,11 @@ loss of connectivity. The default value for Cassandra is 2000 ms.
::
"Dhcp4": { "hosts-database": { "disable-dhcp-on-db-loss" : true, ... }, ... }
"Dhcp4": { "hosts-database": { "disable-service-on-db-loss" : true, ... }, ... }
The default value for MySQL and PostgreSQL is true, which disables the dhcp
service while trying to automatically recover lost connections.
::
"Dhcp4": { "hosts-database": { "enable-connection-recovery" : true, ... }, ... }
The default value for MySQL and PostgreSQL is true, which enables the server to
automatically recover lost connections.
.. note::
Automatic reconnection to database backends is configured

View File

@@ -475,18 +475,11 @@ loss of connectivity. The default value for Cassandra is 2000 ms.
::
"Dhcp6": { "lease-database": { "disable-dhcp-on-db-loss" : true, ... }, ... }
"Dhcp6": { "lease-database": { "disable-service-on-db-loss" : true, ... }, ... }
The default value for MySQL and PostgreSQL is true, which disables the dhcp
service while trying to automatically recover lost connections.
::
"Dhcp6": { "lease-database": { "enable-connection-recovery" : true, ... }, ... }
The default value for MySQL and PostgreSQL is true, which enables the server to
automatically recover lost connections.
.. note::
Automatic reconnection to database backends is configured
@@ -651,18 +644,11 @@ loss of connectivity. The default value for Cassandra is 2000 ms.
::
"Dhcp6": { "hosts-database": { "disable-dhcp-on-db-loss" : true, ... }, ... }
"Dhcp6": { "hosts-database": { "disable-service-on-db-loss" : true, ... }, ... }
The default value for MySQL and PostgreSQL is true, which disables the dhcp
service while trying to automatically recover lost connections.
::
"Dhcp6": { "hosts-database": { "enable-connection-recovery" : true, ... }, ... }
The default value for MySQL and PostgreSQL is true, which enables the server to
automatically recover lost connections.
.. note::
Automatic reconnection to database backends is configured

View File

@@ -1244,7 +1244,7 @@ ControlledDhcpv4Srv::dbLostCallback(ReconnectCtlPtr db_reconnect_ctl) {
// Disable service until the connection is recovered.
if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
db_reconnect_ctl->alterDHCPState()) {
db_reconnect_ctl->alterServiceState()) {
network_state_->disableService(NetworkState::Origin::DB_CONNECTION);
}
@@ -1272,7 +1272,7 @@ ControlledDhcpv4Srv::dbRecoveredCallback(ReconnectCtlPtr db_reconnect_ctl) {
}
// Enable service after the connection is recovered.
if (db_reconnect_ctl->alterDHCPState()) {
if (db_reconnect_ctl->alterServiceState()) {
network_state_->enableService(NetworkState::Origin::DB_CONNECTION);
}

View File

@@ -527,25 +527,14 @@ ControlCharacterFill [^"\\]|\\["\\/bfnrtu]
}
}
\"disable-dhcp-on-db-loss\" {
\"disable-service-on-db-loss\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::LEASE_DATABASE:
case isc::dhcp::Parser4Context::HOSTS_DATABASE:
case isc::dhcp::Parser4Context::CONFIG_DATABASE:
return isc::dhcp::Dhcp4Parser::make_DISABLE_DHCP_ON_DB_LOSS(driver.loc_);
return isc::dhcp::Dhcp4Parser::make_DISABLE_SERVICE_ON_DB_LOSS(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("disable-dhcp-on-db-loss", driver.loc_);
}
}
\"enable-connection-recovery\" {
switch(driver.ctx_) {
case isc::dhcp::Parser4Context::LEASE_DATABASE:
case isc::dhcp::Parser4Context::HOSTS_DATABASE:
case isc::dhcp::Parser4Context::CONFIG_DATABASE:
return isc::dhcp::Dhcp4Parser::make_ENABLE_CONNECTION_RECOVERY(driver.loc_);
default:
return isc::dhcp::Dhcp4Parser::make_STRING("enable-connection-recovery", driver.loc_);
return isc::dhcp::Dhcp4Parser::make_STRING("disable-service-on-db-loss", driver.loc_);
}
}

View File

@@ -97,8 +97,7 @@ using namespace std;
SERIAL_CONSISTENCY "serial-consistency"
MAX_RECONNECT_TRIES "max-reconnect-tries"
RECONNECT_WAIT_TIME "reconnect-wait-time"
DISABLE_DHCP_ON_DB_LOSS "disable-dhcp-on-db-loss"
ENABLE_CONNECTION_RECOVERY "enable-connection-recovery"
DISABLE_SERVICE_ON_DB_LOSS "disable-service-on-db-loss"
REQUEST_TIMEOUT "request-timeout"
TCP_KEEPALIVE "tcp-keepalive"
TCP_NODELAY "tcp-nodelay"
@@ -910,8 +909,7 @@ database_map_param: database_type
| contact_points
| max_reconnect_tries
| reconnect_wait_time
| disable_dhcp_on_db_loss
| enable_connection_recovery
| disable_service_on_db_loss
| request_timeout
| tcp_keepalive
| tcp_nodelay
@@ -1068,16 +1066,10 @@ reconnect_wait_time: RECONNECT_WAIT_TIME COLON INTEGER {
ctx.stack_.back()->set("reconnect-wait-time", n);
};
disable_dhcp_on_db_loss: DISABLE_DHCP_ON_DB_LOSS COLON BOOLEAN {
ctx.unique("disable-dhcp-on-db-loss", ctx.loc2pos(@1));
disable_service_on_db_loss: DISABLE_SERVICE_ON_DB_LOSS COLON BOOLEAN {
ctx.unique("disable-service-on-db-loss", ctx.loc2pos(@1));
ElementPtr n(new BoolElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("disable-dhcp-on-db-loss", n);
};
enable_connection_recovery: ENABLE_CONNECTION_RECOVERY COLON BOOLEAN {
ctx.unique("enable-connection-recovery", ctx.loc2pos(@1));
ElementPtr n(new BoolElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("enable-connection-recovery", n);
ctx.stack_.back()->set("disable-service-on-db-loss", n);
};
max_row_errors: MAX_ROW_ERRORS COLON INTEGER {

View File

@@ -1263,7 +1263,7 @@ ControlledDhcpv6Srv::dbLostCallback(ReconnectCtlPtr db_reconnect_ctl) {
// Disable service until the connection is recovered.
if (db_reconnect_ctl->retriesLeft() == db_reconnect_ctl->maxRetries() &&
db_reconnect_ctl->alterDHCPState()) {
db_reconnect_ctl->alterServiceState()) {
network_state_->disableService(NetworkState::Origin::DB_CONNECTION);
}
@@ -1291,7 +1291,7 @@ ControlledDhcpv6Srv::dbRecoveredCallback(ReconnectCtlPtr db_reconnect_ctl) {
}
// Enable service after the connection is recovered.
if (db_reconnect_ctl->alterDHCPState()) {
if (db_reconnect_ctl->alterServiceState()) {
network_state_->enableService(NetworkState::Origin::DB_CONNECTION);
}

View File

@@ -725,25 +725,14 @@ ControlCharacterFill [^"\\]|\\["\\/bfnrtu]
}
}
\"disable-dhcp-on-db-loss\" {
\"disable-service-on-db-loss\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::LEASE_DATABASE:
case isc::dhcp::Parser6Context::HOSTS_DATABASE:
case isc::dhcp::Parser6Context::CONFIG_DATABASE:
return isc::dhcp::Dhcp6Parser::make_DISABLE_DHCP_ON_DB_LOSS(driver.loc_);
return isc::dhcp::Dhcp6Parser::make_DISABLE_SERVICE_ON_DB_LOSS(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("disable-dhcp-on-db-loss", driver.loc_);
}
}
\"enable-connection-recovery\" {
switch(driver.ctx_) {
case isc::dhcp::Parser6Context::LEASE_DATABASE:
case isc::dhcp::Parser6Context::HOSTS_DATABASE:
case isc::dhcp::Parser6Context::CONFIG_DATABASE:
return isc::dhcp::Dhcp6Parser::make_ENABLE_CONNECTION_RECOVERY(driver.loc_);
default:
return isc::dhcp::Dhcp6Parser::make_STRING("enable-connection-recovery", driver.loc_);
return isc::dhcp::Dhcp6Parser::make_STRING("disable-service-on-db-loss", driver.loc_);
}
}

View File

@@ -79,8 +79,7 @@ using namespace std;
CONTACT_POINTS "contact-points"
MAX_RECONNECT_TRIES "max-reconnect-tries"
RECONNECT_WAIT_TIME "reconnect-wait-time"
DISABLE_DHCP_ON_DB_LOSS "disable-dhcp-on-db-loss"
ENABLE_CONNECTION_RECOVERY "enable-connection-recovery"
DISABLE_SERVICE_ON_DB_LOSS "disable-service-on-db-loss"
KEYSPACE "keyspace"
CONSISTENCY "consistency"
SERIAL_CONSISTENCY "serial-consistency"
@@ -864,8 +863,7 @@ database_map_param: database_type
| contact_points
| max_reconnect_tries
| reconnect_wait_time
| disable_dhcp_on_db_loss
| enable_connection_recovery
| disable_service_on_db_loss
| request_timeout
| tcp_keepalive
| tcp_nodelay
@@ -962,16 +960,10 @@ reconnect_wait_time: RECONNECT_WAIT_TIME COLON INTEGER {
ctx.stack_.back()->set("reconnect-wait-time", n);
};
disable_dhcp_on_db_loss: DISABLE_DHCP_ON_DB_LOSS COLON BOOLEAN {
ctx.unique("disable-dhcp-on-db-loss", ctx.loc2pos(@1));
disable_service_on_db_loss: DISABLE_SERVICE_ON_DB_LOSS COLON BOOLEAN {
ctx.unique("disable-service-on-db-loss", ctx.loc2pos(@1));
ElementPtr n(new BoolElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("disable-dhcp-on-db-loss", n);
};
enable_connection_recovery: ENABLE_CONNECTION_RECOVERY COLON BOOLEAN {
ctx.unique("enable-connection-recovery", ctx.loc2pos(@1));
ElementPtr n(new BoolElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("enable-connection-recovery", n);
ctx.stack_.back()->set("disable-service-on-db-loss", n);
};
max_row_errors: MAX_ROW_ERRORS COLON INTEGER {

View File

@@ -177,7 +177,7 @@ DatabaseConnection::makeReconnectCtl(const std::string& timer_name) {
bool disable_dhcp = true;
try {
parm_str = getParameter("disable-dhcp-on-db-loss");
parm_str = getParameter("disable-service-on-db-loss");
disable_dhcp = boost::lexical_cast<bool>(parm_str);
} catch (...) {
// Wasn't specified so we'll use default of true;
@@ -257,8 +257,7 @@ DatabaseConnection::toElement(const ParameterMap& params) {
} else if ((keyword == "persist") ||
(keyword == "tcp-nodelay") ||
(keyword == "readonly") ||
(keyword == "disable-dhcp-on-db-loss") ||
(keyword == "enable-connection-recovery")) {
(keyword == "disable-service-on-db-loss")) {
if (value == "true") {
result->set(keyword, isc::data::Element::create(true));
} else if (value == "false") {

View File

@@ -85,20 +85,24 @@ public:
///
class ReconnectCtl {
public:
/// @brief Constructor
/// @brief Constructor.
///
/// @param backend_type type of the caller backend.
/// @param timer_name timer associated to this object
/// @param max_retries maximum number of reconnect attempts to make
/// @param retry_interval amount of time to between reconnect attempts
/// @param timer_name timer associated to this object.
/// @param max_retries maximum number of reconnect attempts to make.
/// @param retry_interval amount of time to between reconnect attempts.
/// @param connection_recovery enable or disable the connection recovery
/// mechanism.
/// @param alter_service_state enable or disable changing service state on
/// connection loss and connection recovery.
ReconnectCtl(const std::string& backend_type, const std::string& timer_name,
unsigned int max_retries, unsigned int retry_interval,
bool connection_recovery, bool alter_dhcp_state) :
bool connection_recovery, bool alter_service_state) :
backend_type_(backend_type), timer_name_(timer_name),
max_retries_(max_retries), retries_left_(max_retries),
retry_interval_(retry_interval),
connection_recovery_(connection_recovery),
alter_dhcp_state_(alter_dhcp_state) {}
alter_service_state_(alter_service_state) {}
/// @brief Returns the type of the caller backend.
std::string backendType() const {
@@ -125,25 +129,25 @@ public:
return (max_retries_);
}
/// @brief Returns the number for retries remaining
/// @brief Returns the number for retries remaining.
unsigned int retriesLeft() {
return (retries_left_);
}
/// @brief Returns the amount of time to wait between reconnect attempts
/// @brief Returns the amount of time to wait between reconnect attempts.
unsigned int retryInterval() {
return (retry_interval_);
}
/// @brief Resets the retries count
/// @brief Resets the retries count.
void resetRetries() {
retries_left_ = max_retries_;
}
/// @brief Return the flag which indicates if the connection loss should
/// disable the dhcp service.
bool alterDHCPState() {
return (alter_dhcp_state_);
/// affect the service.
bool alterServiceState() {
return (alter_service_state_);
}
/// @brief Return the flag which indicates if the connection recovery
@@ -160,13 +164,13 @@ private:
/// @brief Timer associated to this object.
std::string timer_name_;
/// @brief Maximum number of retry attempts to make
/// @brief Maximum number of retry attempts to make.
unsigned int max_retries_;
/// @brief Number of attempts remaining
/// @brief Number of attempts remaining.
unsigned int retries_left_;
/// @brief The amount of time to wait between reconnect attempts
/// @brief The amount of time to wait between reconnect attempts.
unsigned int retry_interval_;
/// @brief Flag which indicates if the connection recovery mechanism is
@@ -174,8 +178,8 @@ private:
bool connection_recovery_;
/// @brief Flag which indicates if the connection loss should affect the
/// dhcp service.
bool alter_dhcp_state_;
/// service.
bool alter_service_state_;
};
/// @brief Pointer to an instance of ReconnectCtl

View File

@@ -62,8 +62,7 @@ DbAccessParser::parse(std::string& access_string,
if ((param.first == "persist") ||
(param.first == "tcp-nodelay") ||
(param.first == "readonly") ||
(param.first == "disable-dhcp-on-db-loss") ||
(param.first == "enable-connection-recovery")) {
(param.first == "disable-service-on-db-loss")) {
values_copy[param.first] = (param.second->boolValue() ?
"true" : "false");

View File

@@ -527,8 +527,7 @@ TEST(DatabaseConnection, toElementDbAccessStringValid) {
"\"connect-timeout\" : 200, \n"
"\"contact-points\": \"contact_str\", \n"
"\"consistency\": \"quorum\", \n"
"\"disable-dhcp-on-db-loss\": true, \n"
"\"enable-connection-recovery\": true, \n"
"\"disable-service-on-db-loss\": true, \n"
"\"serial-consistency\": \"serial\", \n"
"\"host\": \"host_str\", \n"
"\"keyspace\": \"keyspace_str\", \n"