diff --git a/doc/sphinx/api-files.txt b/doc/sphinx/api-files.txt index 51346dd3e77445bba08639c585c9ca80bb43a3fd..38f39bbc84c30539a3f8b6105be737b7f93bc102 100644 --- a/doc/sphinx/api-files.txt +++ b/doc/sphinx/api-files.txt @@ -12,6 +12,7 @@ api/class-del.json api/class-get.json api/class-list.json api/class-update.json +api/config-backend-pull.json api/config-get.json api/config-reload.json api/config-set.json @@ -129,7 +130,6 @@ api/reservation-get-all.json api/reservation-get-by-hostname.json api/reservation-get-page.json api/server-tag-get.json -api/server-update.json api/shutdown.json api/statistic-get-all.json api/statistic-get.json diff --git a/doc/sphinx/api/server-update.json b/doc/sphinx/api/config-backend-pull.json similarity index 80% rename from doc/sphinx/api/server-update.json rename to doc/sphinx/api/config-backend-pull.json index a0eeb42b5f8afe352518cac6694a166bef9b1214..5c8db8f412f9b42315de23019ee630c67554d6cd 100644 --- a/doc/sphinx/api/server-update.json +++ b/doc/sphinx/api/config-backend-pull.json @@ -6,11 +6,11 @@ ], "cmd-syntax": [ "{", - " \"command\": \"server-update\"", + " \"command\": \"config-backend-pull\"", "}" ], - "description": "See ", - "name": "server-update", + "description": "See ", + "name": "config-backend-pull", "resp-comment": [ "When no Config Backends are configured this command returns empty (3); ", "If an error occurs error (1) is returned with the error details; ", diff --git a/doc/sphinx/arm/ctrl-channel.rst b/doc/sphinx/arm/ctrl-channel.rst index 3b839f51f5fe1c1660e0a852c0a085fe76133d65..f5e0b5452d151f98b164e6ae7cf4e5caf22d7325 100644 --- a/doc/sphinx/arm/ctrl-channel.rst +++ b/doc/sphinx/arm/ctrl-channel.rst @@ -546,12 +546,12 @@ The server-tag-get Command: The ``server-tag-get`` command returns the configured server tag of the DHCPv4 or DHCPv6 server (:ref:`cb-sharing` explains the server tag concept) -.. _command-server-update: +.. _command-config-backend-pull: -The server-update Command: +The config-backend-pull Command: -------------------------- -The ``server-update`` command triggers the polling of Config Backends +The ``config-backend-pull`` command triggers the polling of Config Backends (which should be configured for this command to do something) explained in :ref:`dhcp4-cb-json`. diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index f870bebf34e3db8081f24cf90812b0b576fe5285..3f617f73588076cdfb758a2f83fbb9331f73d716 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -5891,7 +5891,7 @@ server's performance, because the server needs to make at least one query to the database to discover the pending configuration updates. The default value of the ``config-fetch-wait-time`` is 30 seconds. -The ``server-update`` command can be used to force the server to +The ``config-backend-pull`` command can be used to force the server to immediately poll the configuration changes from the database and avoid waiting for the next fetch cycle. The command was added in 1.7.1 Kea release for DHCPv4 and DHCPv6 servers. diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.cc b/src/bin/dhcp4/ctrl_dhcp4_srv.cc index 3b4af1a3529a12518d7b547bc97c36ad106ffde8..08f9bc0615e909bef6d4729ba4afec88e504a1c2 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.cc +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.cc @@ -545,7 +545,7 @@ ControlledDhcpv4Srv::commandServerTagGetHandler(const std::string&, } ConstElementPtr -ControlledDhcpv4Srv::commandServerUpdateHandler(const std::string&, +ControlledDhcpv4Srv::commandConfigBackendPullHandler(const std::string&, ConstElementPtr) { auto ctl_info = CfgMgr::instance().getCurrentCfg()->getConfigControlInfo(); if (!ctl_info) { @@ -564,8 +564,7 @@ ControlledDhcpv4Srv::commandServerUpdateHandler(const std::string&, auto mode = CBControlDHCPv4::FetchMode::FETCH_UPDATE; server_->getCBControl()->databaseConfigFetch(srv_cfg, mode); } catch (const std::exception& ex) { - LOG_ERROR(dhcp4_logger, DHCP4_CB_FETCH_UPDATES_FAIL) - .arg("server-update command") + LOG_ERROR(dhcp4_logger, DHCP4_CB_PULL_FAIL) .arg(ex.what()); return (createAnswer(CONTROL_RESULT_ERROR, "Server update failed: " + string(ex.what()))); @@ -630,8 +629,8 @@ ControlledDhcpv4Srv::processCommand(const string& command, } else if (command == "server-tag-get") { return (srv->commandServerTagGetHandler(command, args)); - } else if (command == "server-update") { - return (srv->commandServerUpdateHandler(command, args)); + } else if (command == "config-backend-pull") { + return (srv->commandConfigBackendPullHandler(command, args)); } ConstElementPtr answer = isc::config::createAnswer(1, @@ -840,6 +839,9 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t server_port /*= DHCP4_SERVER_P CommandMgr::instance().registerCommand("build-report", boost::bind(&ControlledDhcpv4Srv::commandBuildReportHandler, this, _1, _2)); + CommandMgr::instance().registerCommand("config-backend-pull", + boost::bind(&ControlledDhcpv4Srv::commandConfigBackendPullHandler, this, _1, _2)); + CommandMgr::instance().registerCommand("config-get", boost::bind(&ControlledDhcpv4Srv::commandConfigGetHandler, this, _1, _2)); @@ -870,9 +872,6 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t server_port /*= DHCP4_SERVER_P CommandMgr::instance().registerCommand("server-tag-get", boost::bind(&ControlledDhcpv4Srv::commandServerTagGetHandler, this, _1, _2)); - CommandMgr::instance().registerCommand("server-update", - boost::bind(&ControlledDhcpv4Srv::commandServerUpdateHandler, this, _1, _2)); - CommandMgr::instance().registerCommand("shutdown", boost::bind(&ControlledDhcpv4Srv::commandShutdownHandler, this, _1, _2)); @@ -931,6 +930,7 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() { // Deregister any registered commands (please keep in alphabetic order) CommandMgr::instance().deregisterCommand("build-report"); + CommandMgr::instance().deregisterCommand("config-backend-pull"); CommandMgr::instance().deregisterCommand("config-get"); CommandMgr::instance().deregisterCommand("config-reload"); CommandMgr::instance().deregisterCommand("config-set"); @@ -941,7 +941,6 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() { CommandMgr::instance().deregisterCommand("leases-reclaim"); CommandMgr::instance().deregisterCommand("libreload"); CommandMgr::instance().deregisterCommand("server-tag-get"); - CommandMgr::instance().deregisterCommand("server-update"); CommandMgr::instance().deregisterCommand("shutdown"); CommandMgr::instance().deregisterCommand("statistic-get"); CommandMgr::instance().deregisterCommand("statistic-get-all"); @@ -1078,7 +1077,6 @@ ControlledDhcpv4Srv::cbFetchUpdates(const SrvConfigPtr& srv_cfg, } catch (const std::exception& ex) { LOG_ERROR(dhcp4_logger, DHCP4_CB_FETCH_UPDATES_FAIL) - .arg("periodic poll") .arg(ex.what()); // We allow at most 10 consecutive failures after which we stop diff --git a/src/bin/dhcp4/ctrl_dhcp4_srv.h b/src/bin/dhcp4/ctrl_dhcp4_srv.h index 39a2feed059ade16e95e1973e7931cb4eb368533..d67501da50f2d8a8b958be621a6665ec98f60676 100644 --- a/src/bin/dhcp4/ctrl_dhcp4_srv.h +++ b/src/bin/dhcp4/ctrl_dhcp4_srv.h @@ -304,9 +304,9 @@ private: commandServerTagGetHandler(const std::string& command, isc::data::ConstElementPtr args); - /// @brief handler for server-update command + /// @brief handler for config-backend-pull command /// - /// This method handles the server-update command, which updates + /// This method handles the config-backend-pull command, which updates /// the server configuration from the Config Backends immediately. /// /// @param command (parameter ignored) @@ -314,8 +314,8 @@ private: /// /// @return status of the command/ isc::data::ConstElementPtr - commandServerUpdateHandler(const std::string& command, - isc::data::ConstElementPtr args); + commandConfigBackendPullHandler(const std::string& command, + isc::data::ConstElementPtr args); /// @brief Reclaims expired IPv4 leases and reschedules timer. /// diff --git a/src/bin/dhcp4/dhcp4_messages.cc b/src/bin/dhcp4/dhcp4_messages.cc index f08d23b89b504c46755462ad07274df1f1bed25c..4935291624ddda7b0c7bdab31123b61a977fcfca 100644 --- a/src/bin/dhcp4/dhcp4_messages.cc +++ b/src/bin/dhcp4/dhcp4_messages.cc @@ -1,4 +1,4 @@ -// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Fri Oct 25 2019 16:40 +// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Fri Oct 25 2019 18:13 #include #include @@ -15,6 +15,7 @@ extern const isc::log::MessageID DHCP4_BUFFER_UNPACK = "DHCP4_BUFFER_UNPACK"; extern const isc::log::MessageID DHCP4_BUFFER_WAIT_SIGNAL = "DHCP4_BUFFER_WAIT_SIGNAL"; extern const isc::log::MessageID DHCP4_CB_FETCH_UPDATES_FAIL = "DHCP4_CB_FETCH_UPDATES_FAIL"; extern const isc::log::MessageID DHCP4_CB_FETCH_UPDATES_RETRIES_EXHAUSTED = "DHCP4_CB_FETCH_UPDATES_RETRIES_EXHAUSTED"; +extern const isc::log::MessageID DHCP4_CB_PULL_FAIL = "DHCP4_CB_PULL_FAIL"; extern const isc::log::MessageID DHCP4_CLASS_ASSIGNED = "DHCP4_CLASS_ASSIGNED"; extern const isc::log::MessageID DHCP4_CLASS_UNCONFIGURED = "DHCP4_CLASS_UNCONFIGURED"; extern const isc::log::MessageID DHCP4_CLASS_UNDEFINED = "DHCP4_CLASS_UNDEFINED"; @@ -150,8 +151,9 @@ const char* values[] = { "DHCP4_BUFFER_RECEIVE_FAIL", "error on attempt to receive packet: %1", "DHCP4_BUFFER_UNPACK", "parsing buffer received from %1 to %2 over interface %3", "DHCP4_BUFFER_WAIT_SIGNAL", "signal received while waiting for next packet, next waiting signal is %1", - "DHCP4_CB_FETCH_UPDATES_FAIL", "error on attempt to fetch configuration updates from the configuration backend(s) for %1: %2", + "DHCP4_CB_FETCH_UPDATES_FAIL", "error on attempt to fetch configuration updates from the configuration backend(s): %1", "DHCP4_CB_FETCH_UPDATES_RETRIES_EXHAUSTED", "maximum number of configuration fetch attempts: 10, has been exhausted without success", + "DHCP4_CB_PULL_FAIL", "error on pull configuration updates from the configuration backend(s): %1", "DHCP4_CLASS_ASSIGNED", "%1: client packet has been assigned to the following class(es): %2", "DHCP4_CLASS_UNCONFIGURED", "%1: client packet belongs to an unconfigured class: %2", "DHCP4_CLASS_UNDEFINED", "required class %1 has no definition", diff --git a/src/bin/dhcp4/dhcp4_messages.h b/src/bin/dhcp4/dhcp4_messages.h index f08447d69bc8f126f88fa05502d1630e3c0186ec..577771ced11dc9c5bf2822b08d10125341e92cf0 100644 --- a/src/bin/dhcp4/dhcp4_messages.h +++ b/src/bin/dhcp4/dhcp4_messages.h @@ -1,4 +1,4 @@ -// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Fri Oct 25 2019 16:40 +// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Fri Oct 25 2019 18:13 #ifndef DHCP4_MESSAGES_H #define DHCP4_MESSAGES_H @@ -16,6 +16,7 @@ extern const isc::log::MessageID DHCP4_BUFFER_UNPACK; extern const isc::log::MessageID DHCP4_BUFFER_WAIT_SIGNAL; extern const isc::log::MessageID DHCP4_CB_FETCH_UPDATES_FAIL; extern const isc::log::MessageID DHCP4_CB_FETCH_UPDATES_RETRIES_EXHAUSTED; +extern const isc::log::MessageID DHCP4_CB_PULL_FAIL; extern const isc::log::MessageID DHCP4_CLASS_ASSIGNED; extern const isc::log::MessageID DHCP4_CLASS_UNCONFIGURED; extern const isc::log::MessageID DHCP4_CLASS_UNDEFINED; diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index e400a0cfbb3c453e80147565e8e4db775c1b5469..d88d26cf920378a01e3e1704fe586b4e93f82656 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -46,14 +46,12 @@ by the process. The signal will be handled before the server starts waiting for next packets. The argument specifies the next signal to be handled by the server. -% DHCP4_CB_FETCH_UPDATES_FAIL error on attempt to fetch configuration updates from the configuration backend(s) for %1: %2 +% DHCP4_CB_FETCH_UPDATES_FAIL error on attempt to fetch configuration updates from the configuration backend(s): %1 This error message is issued when the server attempted to fetch configuration updates from the database and this attempt failed. -If the error happens during periodic poll, the server will re-try -according to the configured value of the config-fetch-wait-time -parameter. The arguments contain the fetch context, i.e. during -periodic poll or by the server-update command, and the reason for -failure. +The server will re-try according to the configured value of the +config-fetch-wait-time parameter. The sole argument contains the +reason for failure. % DHCP4_CB_FETCH_UPDATES_RETRIES_EXHAUSTED maximum number of configuration fetch attempts: 10, has been exhausted without success This error indicates that the server has made a number of unsuccessful @@ -62,6 +60,12 @@ The server will continue to operate but won't make any further attempts to fetch configuration updates. The administrator must fix the configuration in the database and reload (or restart) the server. +% DHCP4_CB_PULL_FAIL error on pull configuration updates from the configuration backend(s): %1 +This error message is issued when the server attempted to pull +configuration updates from the database and this attempt failed. +The sole argument which is returned to the config-backend-pull command +caller too contains the reason for failure. + % DHCP4_CLASS_ASSIGNED %1: client packet has been assigned to the following class(es): %2 This debug message informs that incoming packet has been assigned to specified class or classes. This is a normal behavior and indicates successful operation. diff --git a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc index 1452017f948a685acb9b3ccca7ee24616b82f232..3e78609c380ec2d716203ae538755dd8c26c482d 100644 --- a/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc +++ b/src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc @@ -485,7 +485,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, commandsRegistration) { EXPECT_TRUE(command_list.find("\"leases-reclaim\"") != string::npos); EXPECT_TRUE(command_list.find("\"libreload\"") != string::npos); EXPECT_TRUE(command_list.find("\"server-tag-get\"") != string::npos); - EXPECT_TRUE(command_list.find("\"server-update\"") != string::npos); + EXPECT_TRUE(command_list.find("\"config-backend-pull\"") != string::npos); EXPECT_TRUE(command_list.find("\"shutdown\"") != string::npos); EXPECT_TRUE(command_list.find("\"statistic-get\"") != string::npos); EXPECT_TRUE(command_list.find("\"statistic-get-all\"") != string::npos); @@ -1026,15 +1026,15 @@ TEST_F(CtrlChannelDhcpv4SrvTest, serverTagGet) { expected = "{ \"arguments\": { \"server-tag\": \"foobar\" }, \"result\": 0 }"; } -// This test verifies that the DHCP server handles server-update command -TEST_F(CtrlChannelDhcpv4SrvTest, serverUpdate) { +// This test verifies that the DHCP server handles config-backend-pull command +TEST_F(CtrlChannelDhcpv4SrvTest, configBackendPull) { createUnixChannelServer(); std::string response; std::string expected; - // Send the server-update command. Note there is no configured backed. - sendUnixCommand("{ \"command\": \"server-update\" }", response); + // Send the config-backend-pull command. Note there is no configured backed. + sendUnixCommand("{ \"command\": \"config-backend-pull\" }", response); expected = "{ \"result\": 3, \"text\": \"No config backend.\" }"; EXPECT_EQ(expected, response); } @@ -1159,7 +1159,7 @@ TEST_F(CtrlChannelDhcpv4SrvTest, listCommands) { checkListCommands(rsp, "libreload"); checkListCommands(rsp, "version-get"); checkListCommands(rsp, "server-tag-get"); - checkListCommands(rsp, "server-update"); + checkListCommands(rsp, "config-backend-pull"); checkListCommands(rsp, "shutdown"); checkListCommands(rsp, "statistic-get"); checkListCommands(rsp, "statistic-get-all"); diff --git a/src/bin/dhcp4/tests/kea_controller_unittest.cc b/src/bin/dhcp4/tests/kea_controller_unittest.cc index bbd0eaf23a56e4cacf2c30214305cc6f612d29a4..1c408e00fb4716db96dfdb56fa7b2b53af8b587f 100644 --- a/src/bin/dhcp4/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp4/tests/kea_controller_unittest.cc @@ -271,7 +271,7 @@ public: EXPECT_EQ(cb_control->getDatabaseConfigFetchCalls(), 1); ConstElementPtr result = - ControlledDhcpv4Srv::processCommand("server-update", + ControlledDhcpv4Srv::processCommand("config-backend-pull", ConstElementPtr()); EXPECT_EQ(cb_control->getDatabaseConfigFetchCalls(), 2); std::string expected; @@ -891,20 +891,20 @@ TEST_F(JSONFileBackendTest, configBackendTimerWithThrow) { testConfigBackendTimer(1, true); } -// This test verifies that the server will be updated by the server-update -// command. +// This test verifies that the server will be updated by the +// config-backend-pull command. TEST_F(JSONFileBackendTest, configBackendCommand) { testConfigBackendTimer(0, false, true); } -// This test verifies that the server will be updated by the server-update -// command even when updates fail. +// This test verifies that the server will be updated by the +// config-backend-pull command even when updates fail. TEST_F(JSONFileBackendTest, configBackendCommandWithThrow) { testConfigBackendTimer(0, true, true); } -// This test verifies that the server will be updated by the server-update -// command and the timer rescheduled. +// This test verifies that the server will be updated by the +// config-backend-pull command and the timer rescheduled. TEST_F(JSONFileBackendTest, configBackendCommandWithTimer) { testConfigBackendTimer(1, false, true); }