Skip to content

Commit

Permalink
Reset all peers during vmotion interval
Browse files Browse the repository at this point in the history
Use outOfBandConfigUpdated and outOfBandConfigDeleted to figure
out interval and during this period if a disconnect happens
we will reset both peers and fallback to configured list

This avoids issues where we miss the platformConfigDelete
event during vmotion. This basically does the same thing
as what the reset.conf fix would do in case we miss that
event.

Signed-off-by: Madhu Challa <[email protected]>
  • Loading branch information
mchalla committed Sep 3, 2024
1 parent 93dc00b commit dddecaa
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 11 deletions.
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

0 comments on commit dddecaa

Please sign in to comment.