From db20f263254809ed2919170fe578d0df32c5e60e 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” Closes-Bug: #1669301 (cherry picked from commit 0bdd29e9547fa9da39304cc0ff28ac29d671e2d0) Change-Id: I00991c6f371a4523e10dc246165b58db0084e38d --- 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 03dd0bc6d02..5b245b28058 100644 --- a/src/vnsw/agent/oper/global_vrouter.cc +++ b/src/vnsw/agent/oper/global_vrouter.cc @@ -469,7 +469,7 @@ GlobalVrouter::GlobalVrouter(OperDB *oper) *(oper->agent()->event_manager()->io_service()))), agent_route_resync_walker_(new AgentRouteResync(oper->agent())), forwarding_mode_(Agent::L2_L3), flow_export_rate_(kDefaultFlowExportRate), - ecmp_load_balance_() { + ecmp_load_balance_(), configured_(false) { DBTableBase *cfg_db = IFMapTable::FindTable(oper->agent()->db(), "global-vrouter-config"); @@ -505,6 +505,8 @@ void GlobalVrouter::GlobalVrouterConfig(DBTablePartBase *partition, bool resync_route = false; if (node->IsDeleted() == false) { + configured_ = true; + oper_->agent()->connection_state()->Update(); autogen::GlobalVrouterConfig *cfg = static_cast(node->GetObject()); resync_route = @@ -544,6 +546,8 @@ void GlobalVrouter::GlobalVrouterConfig(DBTablePartBase *partition, resync_route = true; flow_export_rate_ = kDefaultFlowExportRate; DeleteFlowAging(); + configured_ = false; + oper_->agent()->connection_state()->Update(); } if (cfg_vxlan_network_identifier_mode != diff --git a/src/vnsw/agent/oper/global_vrouter.h b/src/vnsw/agent/oper/global_vrouter.h index d0f22ab4648..6d883488624 100644 --- a/src/vnsw/agent/oper/global_vrouter.h +++ b/src/vnsw/agent/oper/global_vrouter.h @@ -118,6 +118,7 @@ class GlobalVrouter { uint64_t PendingFabricDnsRequests() const; void ResyncRoutes(); const EcmpLoadBalance &ecmp_load_balance() const; + bool configured() const { return configured_; } friend class AgentUtXmlFlowThreshold; private: @@ -147,6 +148,7 @@ class GlobalVrouter { 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 12fd9285ea3..1ebe3307428 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 @@ -130,6 +131,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) { @@ -193,6 +201,15 @@ void AgentUveBase::VrouterAgentProcessState } } } + 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"; + } + } if (agent_->headless_agent_mode() && reconnects && (num_control_nodes == down_control_nodes)) { message += ", vrouter running in headless mode"; } diff --git a/src/vnsw/agent/uve/agent_uve_base.h b/src/vnsw/agent/uve/agent_uve_base.h index 1711765f9fa..50f605ea503 100644 --- a/src/vnsw/agent/uve/agent_uve_base.h +++ b/src/vnsw/agent/uve/agent_uve_base.h @@ -75,6 +75,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 29b0f5b0c6c..3bdbe4c024f 100644 --- a/src/vnsw/agent/uve/test/test_uve.cc +++ b/src/vnsw/agent/uve/test/test_uve.cc @@ -616,6 +616,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; @@ -623,6 +628,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 */ @@ -635,6 +644,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; @@ -642,6 +656,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 */