From 59ff2b57d982fe52f81bc4c5b07e2bbda34e0778 Mon Sep 17 00:00:00 2001 From: ashoksingh Date: Fri, 3 Mar 2017 14:58:17 +0530 Subject: [PATCH] Send Agent configuration status in NodeStatus UVE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If global-vrouter-config stanza is not downloaded to agent yet, send a message as “No configuration for self” Change-Id: I16c1533b9fd30c154cf78975edccf6c2b8ab7936 Closes-Bug: #1669301 --- src/vnsw/agent/oper/global_vrouter.cc | 6 +++++- src/vnsw/agent/oper/global_vrouter.h | 2 ++ src/vnsw/agent/uve/agent_uve_base.cc | 17 +++++++++++++++++ src/vnsw/agent/uve/agent_uve_base.h | 1 + src/vnsw/agent/uve/test/test_uve.cc | 18 ++++++++++++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/vnsw/agent/oper/global_vrouter.cc b/src/vnsw/agent/oper/global_vrouter.cc index f51134b317e..7da9b991105 100644 --- a/src/vnsw/agent/oper/global_vrouter.cc +++ b/src/vnsw/agent/oper/global_vrouter.cc @@ -465,7 +465,7 @@ GlobalVrouter::GlobalVrouter(Agent *agent) : (this, *(agent->event_manager()->io_service()))), agent_route_resync_walker_(new AgentRouteResync(agent)), forwarding_mode_(Agent::L2_L3), flow_export_rate_(kDefaultFlowExportRate), - ecmp_load_balance_() { + ecmp_load_balance_(), configured_(false) { } GlobalVrouter::~GlobalVrouter() { @@ -482,11 +482,15 @@ void GlobalVrouter::CreateDBClients() { void GlobalVrouter::ConfigDelete(IFMapNode *node) { GlobalVrouterConfig(node); + configured_ = false; + agent()->connection_state()->Update(); return; } void GlobalVrouter::ConfigAddChange(IFMapNode *node) { GlobalVrouterConfig(node); + configured_ = true; + agent()->connection_state()->Update(); return; } diff --git a/src/vnsw/agent/oper/global_vrouter.h b/src/vnsw/agent/oper/global_vrouter.h index 2983d678c3f..6e83af439b1 100644 --- a/src/vnsw/agent/oper/global_vrouter.h +++ b/src/vnsw/agent/oper/global_vrouter.h @@ -121,6 +121,7 @@ class GlobalVrouter : public OperIFMapTable { uint64_t PendingFabricDnsRequests() const; void ResyncRoutes(); const EcmpLoadBalance &ecmp_load_balance() const; + bool configured() const { return configured_; } friend class AgentUtXmlFlowThreshold; private: @@ -148,6 +149,7 @@ class GlobalVrouter : public OperIFMapTable { int32_t flow_export_rate_; FlowAgingTimeoutMap flow_aging_timeout_map_; EcmpLoadBalance ecmp_load_balance_; + bool configured_; //true when global-vrouter-config stanza is present }; #endif // vnsw_agent_global_router_h_ diff --git a/src/vnsw/agent/uve/agent_uve_base.cc b/src/vnsw/agent/uve/agent_uve_base.cc index 8701101d98a..900ad82d38b 100644 --- a/src/vnsw/agent/uve/agent_uve_base.cc +++ b/src/vnsw/agent/uve/agent_uve_base.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -109,6 +110,13 @@ void AgentUveBase::UpdateMessage(const ConnectionInfo &cinfo, } } +bool AgentUveBase::HasSelfConfiguration() const { + if (!agent_ || !agent_->oper_db() || !agent_->oper_db()->global_vrouter()) { + return false; + } + return agent_->oper_db()->global_vrouter()->configured(); +} + void AgentUveBase::VrouterAgentProcessState (const std::vector &cinfos, ProcessState::type &pstate, std::string &message) { @@ -163,6 +171,15 @@ void AgentUveBase::VrouterAgentProcessState if (!is_cup) { message += " connection down"; } + if (!HasSelfConfiguration()) { + // waiting for Global vrouter config + pstate = ProcessState::NON_FUNCTIONAL; + if (message.empty()) { + message = "No Configuration for self"; + } else { + message += ", No Configuration for self"; + } + } for (int i = 0; i < MAX_XMPP_SERVERS; i++) { if (!agent_->controller_ifmap_xmpp_server(i).empty()) { if (agent_->stats()->xmpp_reconnects(i) >= 1) { diff --git a/src/vnsw/agent/uve/agent_uve_base.h b/src/vnsw/agent/uve/agent_uve_base.h index 6d60be398ca..12dd56b37fb 100644 --- a/src/vnsw/agent/uve/agent_uve_base.h +++ b/src/vnsw/agent/uve/agent_uve_base.h @@ -79,6 +79,7 @@ class AgentUveBase { process::ProcessState::type &state, std::string &message); void UpdateMessage(const process::ConnectionInfo &info, std::string &message); + bool HasSelfConfiguration() const; Agent *agent_; uint64_t bandwidth_intvl_; //in microseconds diff --git a/src/vnsw/agent/uve/test/test_uve.cc b/src/vnsw/agent/uve/test/test_uve.cc index 7ad8e5c0870..a379d908afe 100644 --- a/src/vnsw/agent/uve/test/test_uve.cc +++ b/src/vnsw/agent/uve/test/test_uve.cc @@ -598,6 +598,11 @@ TEST_F(UveTest, NodeStatus_Functional_1) { "control-node:1.1.1.2", "1.1.1.2:0", g_process_info_constants.ConnectionStatusNames.find(ConnectionStatus::UP)->second}, }; + /* DelLinkLocalConfig will add emply global-vrouter-config stanza. + * global-vrouter-config is required to make process state as functional + */ + DelLinkLocalConfig(); + client->WaitForIdle(); std::vector cinfos; ProcessState::type pstate; std::string msg; @@ -605,6 +610,10 @@ TEST_F(UveTest, NodeStatus_Functional_1) { EXPECT_EQ(2U, cinfos.size()); GetProcessState(cinfos, pstate, msg); EXPECT_EQ(pstate, ProcessState::FUNCTIONAL); + + //cleanup + DeleteGlobalVrouterConfig(); + client->WaitForIdle(); } /* Only one control-node connection up. Agent should be functional */ @@ -617,6 +626,11 @@ TEST_F(UveTest, NodeStatus_Functional_2) { "control-node:1.1.1.2", "1.1.1.2:0", g_process_info_constants.ConnectionStatusNames.find(ConnectionStatus::UP)->second}, }; + /* DelLinkLocalConfig will add emply global-vrouter-config stanza. + * global-vrouter-config is required to make process state as functional + */ + DelLinkLocalConfig(); + client->WaitForIdle(); std::vector cinfos; ProcessState::type pstate; std::string msg; @@ -624,6 +638,10 @@ TEST_F(UveTest, NodeStatus_Functional_2) { EXPECT_EQ(2U, cinfos.size()); GetProcessState(cinfos, pstate, msg); EXPECT_EQ(pstate, ProcessState::FUNCTIONAL); + + //cleanup + DeleteGlobalVrouterConfig(); + client->WaitForIdle(); } /* Both control-node connections down. Agent should be non-functional */