Commit f3f5125e authored by Francis Dupont's avatar Francis Dupont Committed by Marcin Siodelski

[#1041] Addressed new comments

parent 5645c894
......@@ -557,15 +557,14 @@ The ``status-get`` command returns server runtime information:
secondary, ...) and scopes (i.e. what the server is actually
processing).
* remote: for the remote server the perceived state and the role
* remote: for the remote server the last known state and the role
(scopes should be available in a future release)
.. note::
The HA local server does not know the real state of the HA remote
server (so the perceived state vs the state). The command (or the
``ha-heartbeat``) should be sent to the remote server as explained
in HA :ref:`ha-server-states`.
The HA local server does not always know the current state of the
HA remote server. The command (or the ``ha-heartbeat``) should be
sent to the remote server as explained in HA :ref:`ha-server-states`.
.. _command-server-tag-get:
......
......@@ -584,8 +584,11 @@ ControlledDhcpv4Srv::commandStatusGetHandler(const string&,
status->set("pid", Element::create(static_cast<int>(getpid())));
auto now = boost::posix_time::second_clock::universal_time();
auto uptime = now - start_;
status->set("uptime", Element::create(uptime.total_seconds()));
// Sanity check: start_ is always initialized.
if (!start_.is_not_a_date_time()) {
auto uptime = now - start_;
status->set("uptime", Element::create(uptime.total_seconds()));
}
auto last_commit = CfgMgr::instance().getCurrentCfg()->getLastCommitTime();
if (!last_commit.is_not_a_date_time()) {
......
......@@ -1031,6 +1031,9 @@ TEST_F(CtrlChannelDhcpv4SrvTest, serverTagGet) {
TEST_F(CtrlChannelDhcpv4SrvTest, statusGet) {
createUnixChannelServer();
// start_ is initialized by init.
ASSERT_THROW(server_->init("/no/such/file"), BadValue);
std::string response_txt;
// Send the version-get command
......
......@@ -584,8 +584,11 @@ ControlledDhcpv6Srv::commandStatusGetHandler(const string&,
status->set("pid", Element::create(static_cast<int>(getpid())));
auto now = boost::posix_time::second_clock::universal_time();
auto uptime = now - start_;
status->set("uptime", Element::create(uptime.total_seconds()));
// Sanity check: start_ is always initialized.
if (!start_.is_not_a_date_time()) {
auto uptime = now - start_;
status->set("uptime", Element::create(uptime.total_seconds()));
}
auto last_commit = CfgMgr::instance().getCurrentCfg()->getLastCommitTime();
if (!last_commit.is_not_a_date_time()) {
......
......@@ -923,6 +923,9 @@ TEST_F(CtrlChannelDhcpv6SrvTest, getVersion) {
TEST_F(CtrlChannelDhcpv6SrvTest, statusGet) {
createUnixChannelServer();
// start_ is initialized by init.
ASSERT_THROW(server_->init("/no/such/file"), BadValue);
std::string response_txt;
// Send the version-get command
......
......@@ -987,7 +987,7 @@ HAService::commandProcessed() const {
}
try {
state = getPartnerState();
remote->set("received-state", Element::create(stateToString(state)));
remote->set("last-known-state", Element::create(stateToString(state)));
} catch (const std::exception&) {
/* ignore errors */
}
......
......@@ -3051,7 +3051,7 @@ TEST_F(HAServiceStateMachineTest, waitingParterDownLoadBalancingPartnerDown) {
"\"local\": { \"role\": \"primary\", "
"\"scopes\": [ \"server1\", \"server2\" ], "
"\"state\": \"load-balancing\" }, "
"\"remote\": { \"received-state\": \"ready\", "
"\"remote\": { \"last-known-state\": \"ready\", "
"\"role\": \"secondary\" } }";
EXPECT_EQ(expected, ha_servers->str());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment