mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-02 15:05:16 +00:00
[616-error-msgs-contain-references-to-config-file-while-config-backend-is-used] Split commit block to add CB indication in log/error messages
This commit is contained in:
@@ -650,10 +650,6 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
|
|||||||
const HooksConfig& libraries =
|
const HooksConfig& libraries =
|
||||||
CfgMgr::instance().getStagingCfg()->getHooksConfig();
|
CfgMgr::instance().getStagingCfg()->getHooksConfig();
|
||||||
libraries.loadLibraries();
|
libraries.loadLibraries();
|
||||||
|
|
||||||
// If there are config backends, fetch and merge into staging config
|
|
||||||
server.getCBControl()->databaseConfigFetch(srv_cfg,
|
|
||||||
CBControlDHCPv4::FetchMode::FETCH_ALL);
|
|
||||||
}
|
}
|
||||||
catch (const isc::Exception& ex) {
|
catch (const isc::Exception& ex) {
|
||||||
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(ex.what());
|
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg(ex.what());
|
||||||
@@ -668,6 +664,29 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Moved from the commit block to add the config backend indication.
|
||||||
|
if (!rollback) {
|
||||||
|
try {
|
||||||
|
// If there are config backends, fetch and merge into staging config
|
||||||
|
server.getCBControl()->databaseConfigFetch(srv_cfg,
|
||||||
|
CBControlDHCPv4::FetchMode::FETCH_ALL);
|
||||||
|
}
|
||||||
|
catch (const isc::Exception& ex) {
|
||||||
|
std::ostringstream err;
|
||||||
|
err << "during update from config backend database: " << ex.what();
|
||||||
|
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL).arg((err.str()));
|
||||||
|
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str());
|
||||||
|
rollback = true;
|
||||||
|
} catch (...) {
|
||||||
|
// For things like bad_cast in boost::lexical_cast
|
||||||
|
std::ostringstream err;
|
||||||
|
err << "during update from config backend database: "
|
||||||
|
<< "undefined configuration parsing error";
|
||||||
|
LOG_ERROR(dhcp4_logger, DHCP4_PARSER_COMMIT_FAIL);
|
||||||
|
answer = isc::config::createAnswer(CONTROL_RESULT_ERROR, err.str());
|
||||||
|
rollback = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Rollback changes as the configuration parsing failed.
|
// Rollback changes as the configuration parsing failed.
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
|
@@ -6689,7 +6689,9 @@ TEST_F(Dhcp4ParserTest, configControlInfoNoFactory) {
|
|||||||
|
|
||||||
// Should fail because "type=mysql" has no factories.
|
// Should fail because "type=mysql" has no factories.
|
||||||
configure(config, CONTROL_RESULT_ERROR,
|
configure(config, CONTROL_RESULT_ERROR,
|
||||||
"The type of the configuration backend: 'mysql' is not supported");
|
"during update from config backend database: "
|
||||||
|
"The type of the configuration backend: "
|
||||||
|
"'mysql' is not supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
// This test verifies that configuration control info gets populated.
|
// This test verifies that configuration control info gets populated.
|
||||||
|
@@ -773,10 +773,6 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
|
|||||||
const HooksConfig& libraries =
|
const HooksConfig& libraries =
|
||||||
CfgMgr::instance().getStagingCfg()->getHooksConfig();
|
CfgMgr::instance().getStagingCfg()->getHooksConfig();
|
||||||
libraries.loadLibraries();
|
libraries.loadLibraries();
|
||||||
|
|
||||||
// If there are config backends, fetch and merge into staging config
|
|
||||||
server.getCBControl()->databaseConfigFetch(srv_config,
|
|
||||||
CBControlDHCPv6::FetchMode::FETCH_ALL);
|
|
||||||
}
|
}
|
||||||
catch (const isc::Exception& ex) {
|
catch (const isc::Exception& ex) {
|
||||||
LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(ex.what());
|
LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(ex.what());
|
||||||
@@ -793,6 +789,33 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Moved from the commit block to add the config backend indication.
|
||||||
|
if (!rollback) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
// If there are config backends, fetch and merge into staging config
|
||||||
|
server.getCBControl()->databaseConfigFetch(srv_config,
|
||||||
|
CBControlDHCPv6::FetchMode::FETCH_ALL);
|
||||||
|
}
|
||||||
|
catch (const isc::Exception& ex) {
|
||||||
|
std::ostringstream err;
|
||||||
|
err << "during update from config backend database: " << ex.what();
|
||||||
|
LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(err.str());
|
||||||
|
answer = isc::config::createAnswer(2, err.str());
|
||||||
|
// An error occurred, so make sure to restore the original data.
|
||||||
|
rollback = true;
|
||||||
|
} catch (...) {
|
||||||
|
// for things like bad_cast in boost::lexical_cast
|
||||||
|
std::ostringstream err;
|
||||||
|
err << "during update from config backend database: "
|
||||||
|
<< "undefined configuration parsing error";
|
||||||
|
LOG_ERROR(dhcp6_logger, DHCP6_PARSER_COMMIT_FAIL).arg(err.str());
|
||||||
|
answer = isc::config::createAnswer(2, err.str());
|
||||||
|
// An error occurred, so make sure to restore the original data.
|
||||||
|
rollback = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Rollback changes as the configuration parsing failed.
|
// Rollback changes as the configuration parsing failed.
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
// Revert to original configuration of runtime option definitions
|
// Revert to original configuration of runtime option definitions
|
||||||
|
Reference in New Issue
Block a user