Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
450
Issues
450
List
Boards
Labels
Service Desk
Milestones
Merge Requests
75
Merge Requests
75
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
546dd1b4
Commit
546dd1b4
authored
Oct 25, 2019
by
Francis Dupont
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[904-add-ability-to-force-a-cb-update-remotely] Addressed comments for the v4 part
parent
a4b9f16a
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
49 additions
and
44 deletions
+49
-44
doc/sphinx/api-files.txt
doc/sphinx/api-files.txt
+1
-1
doc/sphinx/api/config-backend-pull.json
doc/sphinx/api/config-backend-pull.json
+3
-3
doc/sphinx/arm/ctrl-channel.rst
doc/sphinx/arm/ctrl-channel.rst
+3
-3
doc/sphinx/arm/dhcp4-srv.rst
doc/sphinx/arm/dhcp4-srv.rst
+1
-1
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/ctrl_dhcp4_srv.cc
+8
-10
src/bin/dhcp4/ctrl_dhcp4_srv.h
src/bin/dhcp4/ctrl_dhcp4_srv.h
+4
-4
src/bin/dhcp4/dhcp4_messages.cc
src/bin/dhcp4/dhcp4_messages.cc
+4
-2
src/bin/dhcp4/dhcp4_messages.h
src/bin/dhcp4/dhcp4_messages.h
+2
-1
src/bin/dhcp4/dhcp4_messages.mes
src/bin/dhcp4/dhcp4_messages.mes
+10
-6
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
+6
-6
src/bin/dhcp4/tests/kea_controller_unittest.cc
src/bin/dhcp4/tests/kea_controller_unittest.cc
+7
-7
No files found.
doc/sphinx/api-files.txt
View file @
546dd1b4
...
...
@@ -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
...
...
doc/sphinx/api/
server-update
.json
→
doc/sphinx/api/
config-backend-pull
.json
View file @
546dd1b4
...
...
@@ -6,11 +6,11 @@
],
"cmd-syntax"
:
[
"{"
,
"
\"
command
\"
:
\"
server-update
\"
"
,
"
\"
command
\"
:
\"
config-backend-pull
\"
"
,
"}"
],
"description"
:
"See <xref linkend=
\"
command-
server-update
\"
/>"
,
"name"
:
"
server-update
"
,
"description"
:
"See <xref linkend=
\"
command-
config-backend-pull
\"
/>"
,
"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; "
,
...
...
doc/sphinx/arm/ctrl-channel.rst
View file @
546dd1b4
...
...
@@ -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`.
...
...
doc/sphinx/arm/dhcp4-srv.rst
View file @
546dd1b4
...
...
@@ -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.
...
...
src/bin/dhcp4/ctrl_dhcp4_srv.cc
View file @
546dd1b4
...
...
@@ -545,7 +545,7 @@ ControlledDhcpv4Srv::commandServerTagGetHandler(const std::string&,
}
ConstElementPtr
ControlledDhcpv4Srv
::
command
ServerUpdate
Handler
(
const
std
::
string
&
,
ControlledDhcpv4Srv
::
command
ConfigBackendPull
Handler
(
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
->
command
ServerUpdate
Handler
(
command
,
args
));
}
else
if
(
command
==
"
config-backend-pull
"
)
{
return
(
srv
->
command
ConfigBackendPull
Handler
(
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
...
...
src/bin/dhcp4/ctrl_dhcp4_srv.h
View file @
546dd1b4
...
...
@@ -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
command
ServerUpdate
Handler
(
const
std
::
string
&
command
,
isc
::
data
::
ConstElementPtr
args
);
command
ConfigBackendPull
Handler
(
const
std
::
string
&
command
,
isc
::
data
::
ConstElementPtr
args
);
/// @brief Reclaims expired IPv4 leases and reschedules timer.
///
...
...
src/bin/dhcp4/dhcp4_messages.cc
View file @
546dd1b4
// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Fri Oct 25 2019 1
6:40
// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Fri Oct 25 2019 1
8:13
#include <cstddef>
#include <log/message_types.h>
...
...
@@ -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"
,
...
...
src/bin/dhcp4/dhcp4_messages.h
View file @
546dd1b4
// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Fri Oct 25 2019 1
6:40
// File created from ../../../src/bin/dhcp4/dhcp4_messages.mes on Fri Oct 25 2019 1
8: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
;
...
...
src/bin/dhcp4/dhcp4_messages.mes
View file @
546dd1b4
...
...
@@ -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.
...
...
src/bin/dhcp4/tests/ctrl_dhcp4_srv_unittest.cc
View file @
546dd1b4
...
...
@@ -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"
);
...
...
src/bin/dhcp4/tests/kea_controller_unittest.cc
View file @
546dd1b4
...
...
@@ -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
// co
nfig-backend-pull co
mmand.
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
// co
nfig-backend-pull co
mmand 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
// co
nfig-backend-pull co
mmand and the timer rescheduled.
TEST_F
(
JSONFileBackendTest
,
configBackendCommandWithTimer
)
{
testConfigBackendTimer
(
1
,
false
,
true
);
}
...
...
Tomek Mrugalski
🛰
@tomek
mentioned in issue
#1076 (closed)
·
Jan 27, 2020
mentioned in issue
#1076 (closed)
mentioned in issue #1076
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment