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”

Closes-Bug: #1669301
(cherry picked from commit 0bdd29e)

Change-Id: If7e8a46952404634cf4fbde03d36d350c31ac1f0
  • Loading branch information
ashoksr committed Mar 8, 2017
1 parent 8c8f62d commit afe0fa4
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 @@ -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");
Expand Down Expand Up @@ -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<autogen::GlobalVrouterConfig *>(node->GetObject());
resync_route =
Expand Down Expand Up @@ -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 !=
Expand Down
2 changes: 2 additions & 0 deletions src/vnsw/agent/oper/global_vrouter.h
Expand Up @@ -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:
Expand Down Expand Up @@ -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_
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 @@ -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<ConnectionInfo> &cinfos,
ProcessState::type &pstate, std::string &message) {
Expand Down Expand Up @@ -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";
}
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 @@ -616,13 +616,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 @@ -635,13 +644,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 afe0fa4

Please sign in to comment.