Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Vrouter changes to honor the new set of services sent by discovery ir…
…respective of the

current state of connection to control-node or dns-server.

a) Do not send update connection info after deleting the connection info, this results in the
library creating a new connection info ds. (not_ready event is triggered after connection
info is deleted)

b) Do not remove stale entries as we want to keep working with older entries in case the
   discovery server returns a smaller list of servers or empty server list.

Change-Id: I1fdc0a4fd1fbafea9b225ca94699060f9e866e00
Partial-Bug: #145947
  • Loading branch information
nipak committed Aug 4, 2015
1 parent 59c6af4 commit a2057b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 50 deletions.
54 changes: 5 additions & 49 deletions src/vnsw/agent/controller/controller_init.cc
Expand Up @@ -310,9 +310,7 @@ void VNController::DeleteConnectionInfo(const std::string &addr, bool is_dns)

void VNController::DisConnectControllerIfmapServer(uint8_t idx) {

DeleteConnectionInfo(agent_->controller_ifmap_xmpp_server(idx), false);

// Managed Delete of XmppClient object, which deletes the
// Managed Delete of XmppClient object, which deletes the
// dependent XmppClientConnection object and
// scoped XmppChannel object
XmppClient *xc = agent_->controller_ifmap_xmpp_client(idx);
Expand All @@ -333,6 +331,7 @@ void VNController::DisConnectControllerIfmapServer(uint8_t idx) {
delete agent_->controller_ifmap_xmpp_init(idx);
agent_->set_controller_ifmap_xmpp_init(NULL, idx);

DeleteConnectionInfo(agent_->controller_ifmap_xmpp_server(idx), false);
agent_->reset_controller_ifmap_xmpp_server(idx);
}

Expand Down Expand Up @@ -401,9 +400,7 @@ bool VNController::ApplyDiscoveryXmppServicesInternal(std::vector<DSResponse> re
agent_->set_controller_ifmap_xmpp_port(dr.ep.port(), xs_idx);
break;

} else if (agent_->controller_xmpp_channel(xs_idx) &&
(agent_->controller_xmpp_channel(xs_idx)->GetXmppChannel()->
GetPeerState() == xmps::NOT_READY)) {
} else if (agent_->controller_xmpp_channel(xs_idx)) {

if (AgentXmppServerExists(
agent_->controller_ifmap_xmpp_server(xs_idx), resp)) {
Expand All @@ -429,25 +426,6 @@ bool VNController::ApplyDiscoveryXmppServicesInternal(std::vector<DSResponse> re
}
}

/* Remove stale Servers if DOWN */
for (uint8_t idx = 0; idx < MAX_XMPP_SERVERS; idx++) {
if (agent_->controller_xmpp_channel(idx) != NULL) {

if (!AgentXmppServerExists(
agent_->controller_ifmap_xmpp_server(idx), resp)) {

if (agent_->controller_xmpp_channel(idx)->GetXmppChannel()->
GetPeerState() == xmps::NOT_READY) {

CONTROLLER_TRACE(DiscoveryConnection, "Cleanup Older Xmpp ",
idx, agent_->controller_ifmap_xmpp_server(idx), "");
DisConnectControllerIfmapServer(idx);
agent_->reset_controller_ifmap_xmpp_server(idx);
}
}
}
}

XmppServerConnect();
return true;
}
Expand All @@ -469,8 +447,6 @@ AgentDnsXmppChannel *VNController::FindAgentDnsXmppChannel(

void VNController::DisConnectDnsServer(uint8_t idx) {

DeleteConnectionInfo(agent_->dns_server(idx), true);

// Managed Delete of XmppClient object, which deletes the
// dependent XmppClientConnection object and
// scoped_ptr XmppChannel
Expand All @@ -487,6 +463,7 @@ void VNController::DisConnectDnsServer(uint8_t idx) {
delete agent_->dns_xmpp_init(idx);
agent_->set_dns_xmpp_init(NULL, idx);

DeleteConnectionInfo(agent_->dns_server(idx), true);
agent_->reset_dns_server(idx);
}

Expand Down Expand Up @@ -534,9 +511,7 @@ void VNController::ApplyDiscoveryDnsXmppServices(std::vector<DSResponse> resp) {
agent_->set_dns_server_port(dr.ep.port(), xs_idx);
break;

} else if (agent_->dns_xmpp_channel(xs_idx) &&
(agent_->dns_xmpp_channel(xs_idx)->GetXmppChannel()->GetPeerState()
== xmps::NOT_READY)) {
} else if (agent_->dns_xmpp_channel(xs_idx)) {

if (AgentXmppServerExists(
agent_->dns_server(xs_idx), resp)) {
Expand All @@ -561,25 +536,6 @@ void VNController::ApplyDiscoveryDnsXmppServices(std::vector<DSResponse> resp) {
}
}

/* Remove stale Servers if DOWN*/
for (uint8_t idx = 0; idx < MAX_XMPP_SERVERS; idx++) {
if (agent_->dns_xmpp_channel(idx) != NULL) {

if (!AgentXmppServerExists(
agent_->dns_server(idx), resp)) {

if (agent_->dns_xmpp_channel(idx)->GetXmppChannel()->
GetPeerState() == xmps::NOT_READY) {

CONTROLLER_TRACE(DiscoveryConnection, "Cleanup Older Dns Xmpp",
idx, agent_->dns_server(idx), "");
DisConnectDnsServer(idx);
agent_->reset_dns_server(idx);
}
}
}
}

DnsXmppServerConnect();
}

Expand Down
6 changes: 5 additions & 1 deletion src/vnsw/agent/test/test_xmpp_discovery.cc
Expand Up @@ -477,7 +477,11 @@ TEST_F(AgentXmppUnitTest, XmppConnection_Discovery_TimedOut) {
WAIT_FOR(1000, 10000,
agent_->controller_xmpp_channel(0)->GetXmppChannel()->GetPeerState()
== xmps::READY);
EXPECT_TRUE(agent_->controller_xmpp_channel(1) == NULL);

ASSERT_STREQ(agent_->controller_ifmap_xmpp_server(1).c_str(), "127.0.0.3");
WAIT_FOR(1000, 10000,
agent_->controller_xmpp_channel(1)->GetXmppChannel()->GetPeerState()
== xmps::NOT_READY);

xs4->Shutdown();
client->WaitForIdle();
Expand Down

0 comments on commit a2057b4

Please sign in to comment.