Skip to content

Commit

Permalink
Send Agent configuration status in NodeStatus UVE
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ashoksr committed Mar 3, 2017
1 parent cf5d603 commit 59ff2b5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/vnsw/agent/oper/global_vrouter.cc
Expand Up @@ -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() {
Expand All @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/vnsw/agent/oper/global_vrouter.h
Expand Up @@ -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:
Expand Down Expand Up @@ -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_
17 changes: 17 additions & 0 deletions src/vnsw/agent/uve/agent_uve_base.cc
Expand Up @@ -16,6 +16,7 @@
#include <uve/stats_interval_types.h>
#include <init/agent_param.h>
#include <oper/mirror_table.h>
#include <oper/global_vrouter.h>
#include <uve/vrouter_stats_collector.h>
#include <cmn/agent_stats.h>

Expand Down Expand Up @@ -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<ConnectionInfo> &cinfos,
ProcessState::type &pstate, std::string &message) {
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/uve/agent_uve_base.h
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/vnsw/agent/uve/test/test_uve.cc
Expand Up @@ -598,13 +598,22 @@ 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<ConnectionInfo> cinfos;
ProcessState::type pstate;
std::string msg;
BuildConnectionInfo(cinfos, input, 2);
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 */
Expand All @@ -617,13 +626,22 @@ 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<ConnectionInfo> cinfos;
ProcessState::type pstate;
std::string msg;
BuildConnectionInfo(cinfos, input, 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 */
Expand Down

0 comments on commit 59ff2b5

Please sign in to comment.