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

Skip reset.conf if we processed PlatformConfig del #577

Merged
merged 1 commit into from
Jul 26, 2024
Merged
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
8 changes: 5 additions & 3 deletions agent-ovs/cmd/opflex_agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,11 @@ class AgentLauncher : FSWatcher::Watcher {
break;
}
if (!stopped && need_reset) {
LOG(INFO) << "Disconnect from existing peers and " <<
"fallback to configured list because of configuration update";
framework.resetAllUnconfiguredPeers();
if (agent.shouldReset()) {
LOG(WARNING) << "Disconnect from existing peers and " <<
"fallback to configured list because of configuration update";
framework.resetAllUnconfiguredPeers();
}
need_reset = false;
continue;
}
Expand Down
9 changes: 9 additions & 0 deletions agent-ovs/lib/Agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ void Agent::setProperties(const boost::property_tree::ptree& properties) {
static const std::string OPFLEX_MULTICAST_CACHE_TIMEOUT("opflex.timers.mcast-cache-timeout");
static const std::string OPFLEX_SWITCH_SYNC_DELAY("opflex.timers.switch-sync-delay");
static const std::string OPFLEX_SWITCH_SYNC_DYNAMIC("opflex.timers.switch-sync-dynamic");
static const std::string OPFLEX_RESET_WAIT_DELAY("opflex.timers.reset-wait-delay");
static const std::string DISABLED_FEATURES("feature.disabled");
static const std::string BEHAVIOR_L34FLOWS_WITHOUT_SUBNET("behavior.l34flows-without-subnet");
static const std::string OPFLEX_ASYC_JSON("opflex.asyncjson.enabled");
Expand Down Expand Up @@ -415,6 +416,14 @@ void Agent::setProperties(const boost::property_tree::ptree& properties) {
LOG(INFO) << "Switch Sync Dynamic set to " << switch_sync_dynamic << " seconds";
}

optional<uint32_t> resetWaitDelayOpt =
properties.get_optional<uint32_t>(OPFLEX_RESET_WAIT_DELAY);
if (resetWaitDelayOpt) {
reset_wait_delay = resetWaitDelayOpt.get();
LOG(INFO) << "Reset Wait delay set to " << reset_wait_delay << " seconds";
}
updateResetTime();

optional<const ptree&> rendererPlugins =
properties.get_child_optional(PLUGINS_RENDERER);

Expand Down
1 change: 1 addition & 0 deletions agent-ovs/lib/EndpointManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,7 @@ void EndpointManager::configUpdated(const URI& uri) {

if (!config) {
LOG(WARNING) << "Platform config has been deleted. Disconnect from existing peers and fallback to configured list";
agent.updateResetTime();
framework.resetAllUnconfiguredPeers();
}
}
Expand Down
24 changes: 24 additions & 0 deletions agent-ovs/lib/include/opflexagent/Agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,25 @@ typedef opflex::ofcore::OFConstants::OpflexElementMode opflex_elem_t;
*/
uint32_t getSwitchSyncDynamic() { return switch_sync_dynamic; }

/**
* save the last PlatformConfig delete time
*/
void updateResetTime() {
std::unique_lock<std::mutex> guard(reset_time_mutex);

reset_time = std::chrono::steady_clock::now();
mchalla marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Check if enough time has passed since last PlatformConfig delete / reset
*/
bool shouldReset() {
std::unique_lock<std::mutex> guard(reset_time_mutex);

auto diff = std::chrono::steady_clock::now() - reset_time;
return diff > std::chrono::seconds(reset_wait_delay);
}

/**
* Common function b/w Agent and Server to add all supported universes
* @param root pointer to DmtreeRoot under which the universes will be created
Expand Down Expand Up @@ -361,6 +380,11 @@ typedef opflex::ofcore::OFConstants::OpflexElementMode opflex_elem_t;
/* How long to wait from platform config to switch Sync */
uint32_t switch_sync_delay = 5; /* seconds */
uint32_t switch_sync_dynamic = 0; /* dynamic retry default 0 no retry */
uint32_t reset_wait_delay = 5; /* seconds */
/* Timestamp of last PlatformConfig delete event */
std::chrono::steady_clock::time_point reset_time;
/* mutex to update reset_time */
std::mutex reset_time_mutex;
// startup policy duration from new connection in seconds
uint64_t startupPolicyDuration = 0; /* seconds */
bool localResolveAftConn = false; /* local resolve after conn estb */
Expand Down
6 changes: 6 additions & 0 deletions agent-ovs/opflex-agent-ovs.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@
// Max retries will be 5 so as to not wait
// forever
// "switch-sync-dynamic": 0
//
// skip reset.conf processing if platformConfig
// delete was processed within this interval.
// This is to avoid duplicate reset processing
// for the same event
// "reset-wait-delay": 5
},
// Statistics. Counters for various artifacts.
// mode: can be either
Expand Down