Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset all peers during vmotion interval #589

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions agent-ovs/lib/ExtraConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ void ExtraConfigManager::outOfBandConfigUpdated(const OutOfBandConfigSpec &outOf
mutator.commit();
shared_ptr<OutOfBandConfigSpec> oobSptr(new OutOfBandConfigSpec(outOfBandCfg.tunnelEpAdvInterval));
notifyOutOfBandConfigListeners(oobSptr);
framework.setResetAllPeers(true);
}

void ExtraConfigManager::outOfBandConfigDeleted() {
Expand All @@ -138,6 +139,7 @@ void ExtraConfigManager::outOfBandConfigDeleted() {
mutator.commit();
shared_ptr<OutOfBandConfigSpec> oobSptr;
notifyOutOfBandConfigListeners(oobSptr);
framework.setResetAllPeers(false);
}

void ExtraConfigManager::packetDropLogConfigUpdated(PacketDropLogConfig &dropCfg) {
Expand Down
32 changes: 21 additions & 11 deletions libopflex/engine/OpflexClientConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,21 @@ void OpflexClientConnection::on_state_change(Peer * p, void * data,
case yajr::StateChange::DISCONNECT:
LOG(INFO) << "[" << conn->getRemotePeer() << "] "
<< "Disconnected";

uv_timer_stop(conn->handshake_timer);
conn->active = false;
conn->ready = false;
conn->handler->disconnected();
conn->cleanup();

if (!conn->closing)
conn->pool->updatePeerStatus(conn->hostname, conn->port,
PeerStatusListener::CONNECTING);
break;
if (conn->pool->getResetAllPeers() &&
!conn->pool->isConfiguredPeer(conn->hostname, conn->port)) {
conn->resetAllUnconfiguredPeers();
} else {
uv_timer_stop(conn->handshake_timer);
conn->active = false;
conn->ready = false;
conn->handler->disconnected();
conn->cleanup();

if (!conn->closing)
conn->pool->updatePeerStatus(conn->hostname, conn->port,
PeerStatusListener::CONNECTING);
}
break;
case yajr::StateChange::TRANSPORT_FAILURE:
{
char buf[120];
Expand Down Expand Up @@ -210,6 +214,12 @@ void OpflexClientConnection::connectionFailure() {
}
}

void OpflexClientConnection::resetAllUnconfiguredPeers() {
LOG(WARNING) << "Disconnect from existing peers and fallback to configured list";
pool->resetAllUnconfiguredPeers();
pool->addConfiguredPeers();
}

void OpflexClientConnection::messagesReady() {
pool->messagesReady();
}
Expand Down
1 change: 1 addition & 0 deletions libopflex/engine/OpflexPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ OpflexPool::OpflexPool(HandlerFactory& factory_,
util::ThreadManager& threadManager_)
: factory(factory_), threadManager(threadManager_),
active(false),
reset_all_peers(false),
client_mode(OFConstants::OpflexElementMode::STITCHED_MODE),
transport_state(OFConstants::OpflexTransportModeState::SEEKING_PROXIES),
ipv4_proxy(0), ipv6_proxy(0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class OpflexClientConnection : public OpflexConnection {
yajr::StateChange::To stateChange,
int error);
void connectionFailure();
void resetAllUnconfiguredPeers();

};

Expand Down
9 changes: 9 additions & 0 deletions libopflex/engine/include/opflex/engine/internal/OpflexPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ class OpflexPool : private boost::noncopyable {
return tunnelMac;
}

void setResetAllPeers(bool value) {
reset_all_peers = value;
}

bool getResetAllPeers() {
return reset_all_peers;
}

/**
* Retrieve OpFlex client stats for each available peer
*
Expand Down Expand Up @@ -422,6 +430,7 @@ class OpflexPool : private boost::noncopyable {
conn_map_t connections;
role_map_t roles;
boost::atomic<bool> active;
boost::atomic<bool> reset_all_peers;

opflex::ofcore::OFConstants::OpflexElementMode client_mode;
opflex::ofcore::OFConstants::OpflexTransportModeState transport_state;
Expand Down
14 changes: 14 additions & 0 deletions libopflex/include/opflex/ofcore/OFFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,20 @@ class OFFramework : private boost::noncopyable {
*/
void deleteMOs(opflex::modb::mointernal::StoreClient::notif_t& notifs);

/**
* Enable or Disable reset_all_peers bool in OpflexPool
* when enabled any peer disconnect will result in all non configured peers
* to disconnect.
* @param value bool current intended reset behavior
*/
void setResetAllPeers(bool value);

/**
* return current value of reset_all_peers bool in OpflexPool
* @return bool current intended reset behavior
*/
bool getResetAllPeers();

/**
* Start the framework. This will start all the framework threads
* and attempt to connect to configured OpFlex peers.
Expand Down
10 changes: 10 additions & 0 deletions libopflex/ofcore/OFFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ void OFFramework::getMacProxy(boost::asio::ip::address_v4 &macProxyAddress ) {
macProxyAddress = pool.getMacProxy();
}

void OFFramework::setResetAllPeers(bool value) {
engine::internal::OpflexPool& pool = pimpl->processor.getPool();
pool.setResetAllPeers(value);
}

bool OFFramework::getResetAllPeers() {
engine::internal::OpflexPool& pool = pimpl->processor.getPool();
return pool.getResetAllPeers();
}

void MockOFFramework::setV4Proxy(const boost::asio::ip::address_v4& v4ProxyAddress ) {
engine::internal::OpflexPool& pool = pimpl->processor.getPool();
pool.setV4Proxy(v4ProxyAddress);
Expand Down