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

[#1041] Addressed new comments

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