diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index 4cd536b915..307c488cfe 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -583,13 +583,13 @@ The possible values are: "Dhcp4": { "lease-database": { "retry-on-startup" : true, ... }, ... } During server startup, the inability to connect to any of the configured -backends is considered fatal only if ``retry-on-startup`` is set to ``false``. -A fatal error is logged and the server exits, based on the idea that the -configuration should be valid at startup. Exiting to the operating system allows -nanny scripts to detect the problem. +backends is considered fatal only if ``retry-on-startup`` is set to ``false`` +(the default). A fatal error is logged and the server exits, based on the idea +that the configuration should be valid at startup. Exiting to the operating +system allows nanny scripts to detect the problem. If ``retry-on-startup`` is set to ``true``, the server will start reconnection attempts even at server startup or on reconfigure events, and will honor the -action specified in ``on-fail`` parameter. +action specified in the ``on-fail`` parameter. The host parameter is used by the MySQL and PostgreSQL backends. @@ -818,13 +818,13 @@ The possible values are: "Dhcp4": { "hosts-database": { "retry-on-startup" : true, ... }, ... } During server startup, the inability to connect to any of the configured -backends is considered fatal only if ``retry-on-startup`` is set to ``false``. -A fatal error is logged and the server exits, based on the idea that the -configuration should be valid at startup. Exiting to the operating system allows -nanny scripts to detect the problem. +backends is considered fatal only if ``retry-on-startup`` is set to ``false`` +(the default). A fatal error is logged and the server exits, based on the idea +that the configuration should be valid at startup. Exiting to the operating +system allows nanny scripts to detect the problem. If ``retry-on-startup`` is set to ``true``, the server will start reconnection attempts even at server startup or on reconfigure events, and will honor the -action specified in ``on-fail`` parameter. +action specified in the ``on-fail`` parameter. Finally, the credentials of the account under which the server will access the database should be set: diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index 93ba23774a..9c19b1460d 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -539,13 +539,13 @@ The possible values are: "Dhcp6": { "lease-database": { "retry-on-startup" : true, ... }, ... } During server startup, the inability to connect to any of the configured -backends is considered fatal only if ``retry-on-startup`` is set to ``false``. -A fatal error is logged and the server exits, based on the idea that the -configuration should be valid at startup. Exiting to the operating system allows -nanny scripts to detect the problem. +backends is considered fatal only if ``retry-on-startup`` is set to ``false`` +(the default). A fatal error is logged and the server exits, based on the idea +that the configuration should be valid at startup. Exiting to the operating +system allows nanny scripts to detect the problem. If ``retry-on-startup`` is set to ``true``, the server will start reconnection attempts even at server startup or on reconfigure events, and will honor the -action specified in ``on-fail`` parameter. +action specified in the ``on-fail`` parameter. The host parameter is used by the MySQL and PostgreSQL backends. @@ -774,13 +774,13 @@ The possible values are: "Dhcp6": { "hosts-database": { "retry-on-startup" : true, ... }, ... } During server startup, the inability to connect to any of the configured -backends is considered fatal only if ``retry-on-startup`` is set to ``false``. -A fatal error is logged and the server exits, based on the idea that the -configuration should be valid at startup. Exiting to the operating system allows -nanny scripts to detect the problem. +backends is considered fatal only if ``retry-on-startup`` is set to ``false`` +(the default). A fatal error is logged and the server exits, based on the idea +that the configuration should be valid at startup. Exiting to the operating +system allows nanny scripts to detect the problem. If ``retry-on-startup`` is set to ``true``, the server will start reconnection attempts even at server startup or on reconfigure events, and will honor the -action specified in ``on-fail`` parameter. +action specified in the ``on-fail`` parameter. Finally, the credentials of the account under which the server will access the database should be set: diff --git a/doc/sphinx/arm/hooks-legal-log.rst b/doc/sphinx/arm/hooks-legal-log.rst index fafaf16a4a..be2a07c196 100644 --- a/doc/sphinx/arm/hooks-legal-log.rst +++ b/doc/sphinx/arm/hooks-legal-log.rst @@ -1085,10 +1085,10 @@ the connection to the database backend is not restored according to the continues serving clients while this mechanism is activated. During server startup, the inability to connect to any of the configured -backends is considered fatal only if ``retry-on-startup`` is set to ``false``. -A fatal error is logged and the server exits, based on the idea that the -configuration should be valid at startup. Exiting to the operating system allows -nanny scripts to detect the problem. +backends is considered fatal only if ``retry-on-startup`` is set to ``false`` +(the default). A fatal error is logged and the server exits, based on the idea +that the configuration should be valid at startup. Exiting to the operating +system allows nanny scripts to detect the problem. If ``retry-on-startup`` is set to ``true``, the server will start reconnection attempts even at server startup or on reconfigure events, and will honor the -action specified in ``on-fail`` parameter. +action specified in the ``on-fail`` parameter. diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc index 4321d284d9..cf080f8914 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_impl.cc @@ -72,7 +72,7 @@ MySqlConfigBackendImpl(const std::string& space, std::pair code_version(MYSQL_SCHEMA_VERSION_MAJOR, MYSQL_SCHEMA_VERSION_MINOR); - std::string timer_name = ""; + std::string timer_name; bool retry = false; if (parameters.count("retry-on-startup")) { if (parameters.at("retry-on-startup") == "true") { diff --git a/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.cc b/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.cc index a8f029210e..2732f7a62c 100644 --- a/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.cc +++ b/src/hooks/dhcp/pgsql_cb/pgsql_cb_impl.cc @@ -117,7 +117,7 @@ PgSqlConfigBackendImpl::PgSqlConfigBackendImpl(const std::string& space, std::pair code_version(PGSQL_SCHEMA_VERSION_MAJOR, PGSQL_SCHEMA_VERSION_MINOR); - std::string timer_name = ""; + std::string timer_name; bool retry = false; if (parameters.count("retry-on-startup")) { if (parameters.at("retry-on-startup") == "true") { diff --git a/src/lib/dhcpsrv/lease_mgr.h b/src/lib/dhcpsrv/lease_mgr.h index eb604f7d0d..b3ac56bc07 100644 --- a/src/lib/dhcpsrv/lease_mgr.h +++ b/src/lib/dhcpsrv/lease_mgr.h @@ -818,7 +818,7 @@ public: /// B>=A and B=C (it is ok to have newer backend, as it should be backward /// compatible) /// Also if B>C, some database upgrade procedure may be triggered - virtual VersionPair getVersion(const std::string& timer_name = "") const = 0; + virtual VersionPair getVersion(const std::string& timer_name = std::string()) const = 0; /// @brief Commit Transactions /// diff --git a/src/lib/dhcpsrv/mysql_host_data_source.cc b/src/lib/dhcpsrv/mysql_host_data_source.cc index bdc6f640bc..8a84817b59 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.cc +++ b/src/lib/dhcpsrv/mysql_host_data_source.cc @@ -2178,7 +2178,7 @@ public: /// /// @throw isc::dhcp::DbOperationError An operation on the open database /// has failed. - std::pair getVersion(const std::string& timer_name = "") const; + std::pair getVersion(const std::string& timer_name = std::string()) const; /// @brief Executes statements which inserts a row into one of the tables. /// @@ -2884,7 +2884,7 @@ MySqlHostDataSourceImpl::MySqlHostDataSourceImpl(const DatabaseConnection::Param std::pair code_version(MYSQL_SCHEMA_VERSION_MAJOR, MYSQL_SCHEMA_VERSION_MINOR); - std::string timer_name = ""; + std::string timer_name; bool retry = false; if (parameters.count("retry-on-startup")) { if (parameters.at("retry-on-startup") == "true") { diff --git a/src/lib/dhcpsrv/mysql_host_data_source.h b/src/lib/dhcpsrv/mysql_host_data_source.h index 502c9f3896..10643d1183 100644 --- a/src/lib/dhcpsrv/mysql_host_data_source.h +++ b/src/lib/dhcpsrv/mysql_host_data_source.h @@ -465,7 +465,7 @@ public: /// /// @throw isc::db::DbOperationError An operation on the open database /// has failed. - virtual std::pair getVersion(const std::string& timer_name = "") const; + virtual std::pair getVersion(const std::string& timer_name = std::string()) const; /// @brief Commit Transactions /// diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.cc b/src/lib/dhcpsrv/mysql_lease_mgr.cc index 90af405cd2..6edbd6c3ae 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.cc +++ b/src/lib/dhcpsrv/mysql_lease_mgr.cc @@ -2199,7 +2199,7 @@ MySqlLeaseMgr::MySqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters) std::pair code_version(MYSQL_SCHEMA_VERSION_MAJOR, MYSQL_SCHEMA_VERSION_MINOR); - std::string timer_name = ""; + std::string timer_name; bool retry = false; if (parameters.count("retry-on-startup")) { if (parameters.at("retry-on-startup") == "true") { diff --git a/src/lib/dhcpsrv/mysql_lease_mgr.h b/src/lib/dhcpsrv/mysql_lease_mgr.h index bc673bb5ba..b0b6b37348 100644 --- a/src/lib/dhcpsrv/mysql_lease_mgr.h +++ b/src/lib/dhcpsrv/mysql_lease_mgr.h @@ -695,7 +695,7 @@ public: /// /// @throw isc::db::DbOperationError An operation on the open database has /// failed. - virtual std::pair getVersion(const std::string& timer_name = "") const override; + virtual std::pair getVersion(const std::string& timer_name = std::string()) const override; /// @brief Commit Transactions /// diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.cc b/src/lib/dhcpsrv/pgsql_host_data_source.cc index 4abad5afd3..6a88942bdc 100644 --- a/src/lib/dhcpsrv/pgsql_host_data_source.cc +++ b/src/lib/dhcpsrv/pgsql_host_data_source.cc @@ -1620,7 +1620,7 @@ public: /// /// @throw isc::db::DbOperationError An operation on the open database /// has failed. - std::pair getVersion(const std::string& timer_name = "") const; + std::pair getVersion(const std::string& timer_name = std::string()) const; /// @brief The parameters DatabaseConnection::ParameterMap parameters_; @@ -2301,7 +2301,7 @@ PgSqlHostDataSourceImpl::PgSqlHostDataSourceImpl(const DatabaseConnection::Param std::pair code_version(PGSQL_SCHEMA_VERSION_MAJOR, PGSQL_SCHEMA_VERSION_MINOR); - std::string timer_name = ""; + std::string timer_name; bool retry = false; if (parameters.count("retry-on-startup")) { if (parameters.at("retry-on-startup") == "true") { diff --git a/src/lib/dhcpsrv/pgsql_host_data_source.h b/src/lib/dhcpsrv/pgsql_host_data_source.h index 3870e8295c..61043c575a 100644 --- a/src/lib/dhcpsrv/pgsql_host_data_source.h +++ b/src/lib/dhcpsrv/pgsql_host_data_source.h @@ -517,7 +517,7 @@ public: /// /// @throw isc::db::DbOperationError An operation on the open database /// has failed. - virtual std::pair getVersion(const std::string& timer_name = "") const; + virtual std::pair getVersion(const std::string& timer_name = std::string()) const; /// @brief Commit Transactions /// diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.cc b/src/lib/dhcpsrv/pgsql_lease_mgr.cc index 23e2c44545..97c0973ed5 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.cc +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.cc @@ -1648,7 +1648,7 @@ PgSqlLeaseMgr::PgSqlLeaseMgr(const DatabaseConnection::ParameterMap& parameters) std::pair code_version(PGSQL_SCHEMA_VERSION_MAJOR, PGSQL_SCHEMA_VERSION_MINOR); - std::string timer_name = ""; + std::string timer_name; bool retry = false; if (parameters.count("retry-on-startup")) { if (parameters.at("retry-on-startup") == "true") { diff --git a/src/lib/dhcpsrv/pgsql_lease_mgr.h b/src/lib/dhcpsrv/pgsql_lease_mgr.h index c7525a27d7..dd461b1945 100644 --- a/src/lib/dhcpsrv/pgsql_lease_mgr.h +++ b/src/lib/dhcpsrv/pgsql_lease_mgr.h @@ -671,7 +671,7 @@ public: /// /// @throw isc::db::DbOperationError An operation on the open database has /// failed. - virtual std::pair getVersion(const std::string& timer_name = "") const override; + virtual std::pair getVersion(const std::string& timer_name = std::string()) const override; /// @brief Commit Transactions /// diff --git a/src/lib/dhcpsrv/testutils/generic_cb_recovery_unittest.cc b/src/lib/dhcpsrv/testutils/generic_cb_recovery_unittest.cc index 1bf1dc4e84..8f4e8ba00a 100644 --- a/src/lib/dhcpsrv/testutils/generic_cb_recovery_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_cb_recovery_unittest.cc @@ -85,6 +85,8 @@ GenericConfigBackendDbLostCallbackTest::testRetryOpenDbLostAndRecoveredCallback( std::string access = invalidConnectionString(); access += " retry-on-startup=true"; + // by adding an invalid access will cause the manager factory to throw + // resulting in failure to recreate the manager ConfigControlInfoPtr config_ctl_info(new ConfigControlInfo()); config_ctl_info->addConfigDatabase(access); CfgMgr::instance().getCurrentCfg()->setConfigControlInfo(config_ctl_info); @@ -104,8 +106,6 @@ GenericConfigBackendDbLostCallbackTest::testRetryOpenDbLostAndRecoveredCallback( access = validConnectionString(); CfgMgr::instance().clear(); - // by adding an invalid access will cause the manager factory to throw - // resulting in failure to recreate the manager config_ctl_info.reset(new ConfigControlInfo()); config_ctl_info->addConfigDatabase(access); CfgMgr::instance().getCurrentCfg()->setConfigControlInfo(config_ctl_info); @@ -140,6 +140,8 @@ GenericConfigBackendDbLostCallbackTest::testRetryOpenDbLostAndFailedCallback() { std::string access = invalidConnectionString(); access += " retry-on-startup=true"; + // by adding an invalid access will cause the manager factory to throw + // resulting in failure to recreate the manager ConfigControlInfoPtr config_ctl_info(new ConfigControlInfo()); config_ctl_info->addConfigDatabase(access); CfgMgr::instance().getCurrentCfg()->setConfigControlInfo(config_ctl_info); @@ -186,6 +188,8 @@ GenericConfigBackendDbLostCallbackTest::testRetryOpenDbLostAndRecoveredAfterTime std::string extra = " max-reconnect-tries=3 reconnect-wait-time=1 retry-on-startup=true"; access += extra; + // by adding an invalid access will cause the manager factory to throw + // resulting in failure to recreate the manager ConfigControlInfoPtr config_ctl_info(new ConfigControlInfo()); config_ctl_info->addConfigDatabase(access); CfgMgr::instance().getCurrentCfg()->setConfigControlInfo(config_ctl_info); @@ -260,6 +264,8 @@ GenericConfigBackendDbLostCallbackTest::testRetryOpenDbLostAndFailedAfterTimeout std::string extra = " max-reconnect-tries=3 reconnect-wait-time=1 retry-on-startup=true"; access += extra; + // by adding an invalid access will cause the manager factory to throw + // resulting in failure to recreate the manager ConfigControlInfoPtr config_ctl_info(new ConfigControlInfo()); config_ctl_info->addConfigDatabase(access); CfgMgr::instance().getCurrentCfg()->setConfigControlInfo(config_ctl_info); @@ -429,6 +435,7 @@ GenericConfigBackendDbLostCallbackTest::testDbLostAndFailedCallback() { access = invalidConnectionString(); CfgMgr::instance().clear(); + // by adding an invalid access will cause the manager factory to throw // resulting in failure to recreate the manager config_ctl_info.reset(new ConfigControlInfo()); @@ -494,6 +501,7 @@ GenericConfigBackendDbLostCallbackTest::testDbLostAndRecoveredAfterTimeoutCallba access = invalidConnectionString(); access += extra; CfgMgr::instance().clear(); + // by adding an invalid access will cause the manager factory to throw // resulting in failure to recreate the manager config_ctl_info.reset(new ConfigControlInfo()); @@ -584,6 +592,7 @@ GenericConfigBackendDbLostCallbackTest::testDbLostAndFailedAfterTimeoutCallback( access = invalidConnectionString(); access += extra; CfgMgr::instance().clear(); + // by adding an invalid access will cause the manager factory to throw // resulting in failure to recreate the manager config_ctl_info.reset(new ConfigControlInfo());