Skip to content

Commit

Permalink
Make policy retry delay configurable
Browse files Browse the repository at this point in the history
The retry delay should be configurable, with a default initial
backoff value of 10 seconds. This can be set to larger amounts
for servers that crash under heavy loads from frequent re-requests.
  • Loading branch information
tbachman committed Mar 3, 2023
1 parent 5468de0 commit ac6b294
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
12 changes: 12 additions & 0 deletions agent-ovs/lib/Agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ void Agent::setProperties(const boost::property_tree::ptree& properties) {
static const std::string OPFLEX_PRR_INTERVAL("opflex.timers.prr");
static const std::string OPFLEX_HANDSHAKE("opflex.timers.handshake-timeout");
static const std::string OPFLEX_KEEPALIVE("opflex.timers.keepalive-timeout");
static const std::string OPFLEX_POLICY_RETRY_DELAY("opflex.timers.policy-retry-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 @@ -453,6 +454,16 @@ void Agent::setProperties(const boost::property_tree::ptree& properties) {
LOG(INFO) << "prr timer set to " << prr_timer << " secs";
}

optional<boost::uint_t<64>::fast> policy_retry_delay_present =
properties.get_optional<boost::uint_t<64>::fast>(OPFLEX_POLICY_RETRY_DELAY);
if (policy_retry_delay_present) {
policy_retry_delay_timer = policy_retry_delay_present.get();
if (policy_retry_delay_timer < 10) {
policy_retry_delay_timer = 10; /* min is 10 seconds */
}
LOG(INFO) << "policy retry delay timer set to " << policy_retry_delay_timer << " secs";
}

optional<uint32_t> handshakeOpt = properties.get_optional<uint32_t>(OPFLEX_HANDSHAKE);
if (handshakeOpt) {
peerHandshakeTimeout = handshakeOpt.get();
Expand Down Expand Up @@ -542,6 +553,7 @@ void Agent::applyProperties() {
}

framework.setPrrTimerDuration(prr_timer);
framework.setPolicyRetryDelayTimerDuration(policy_retry_delay_timer);
framework.setHandshakeTimeout(peerHandshakeTimeout);
framework.setKeepaliveTimeout(keepaliveTimeout);
}
Expand Down
2 changes: 2 additions & 0 deletions agent-ovs/lib/include/opflexagent/Agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ typedef opflex::ofcore::OFConstants::OpflexElementMode opflex_elem_t;
// timers
// prr timer - policy resolve request timer
boost::uint_t<64>::fast prr_timer = 7200; /* seconds */
// initial policy retry delay
boost::uint_t<64>::fast policy_retry_delay_timer = 10; /* seconds */
/* handshake timeout */
uint32_t peerHandshakeTimeout = 45000;
/* keepalive timeout */
Expand Down
5 changes: 5 additions & 0 deletions agent-ovs/opflex-agent-ovs.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
// default 7200 secs, min 15 secs
// "prr": 7200,
//
// How long to wait for initial re-request, either
// due to a backoff, or for no response.
// default 10 secs, min 10 secs
// "policy-retry-delay": 10
//
// How long to wait for the initial peer
// handshake to complete (in ms)
// "handshake-timeout" : 45000,
Expand Down
2 changes: 1 addition & 1 deletion libopflex/engine/Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ using util::ThreadManager;
using namespace internal;

static const uint64_t DEFAULT_PROC_DELAY = 250;
static const uint64_t DEFAULT_RETRY_DELAY = 1000*60*2;
static const uint64_t FIRST_XID = (uint64_t)1 << 63;
static const uint32_t MAX_PROCESS = 1024;

Expand Down Expand Up @@ -100,6 +99,7 @@ void Processor::setPrrTimerDuration(uint64_t duration) {
prrTimerDuration = duration;
policyRefTimerDuration = 1000*prrTimerDuration/2;
}

// check whether the object state index has work for us
bool Processor::hasWork(/* out */ obj_state_by_exp::iterator& it) {
if (obj_state.empty()) return false;
Expand Down
3 changes: 2 additions & 1 deletion libopflex/engine/include/opflex/engine/Processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,8 @@ class Processor : public internal::AbstractObjectListener,
/**
* Amount of time to wait before retrying message sends
*/
uint64_t retryDelay;
static const uint64_t DEFAULT_RETRY_DELAY = 1000*60*2;
uint64_t retryDelay = DEFAULT_RETRY_DELAY;

/**
* prr timer duration in secs
Expand Down
6 changes: 6 additions & 0 deletions libopflex/include/opflex/ofcore/OFFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,12 @@ class OFFramework : private boost::noncopyable {
*/
void setPrrTimerDuration(const uint64_t duration);

/**
* set the policy resolve retry delay (prrd) timer durarion.
* @param duration timer duration in milliseconds
*/
void setPolicyRetryDelayTimerDuration(const uint64_t duration);

/**
* Set the peer handshake timeout
* @param timeout peer handshake timeout in milliseconds
Expand Down
4 changes: 4 additions & 0 deletions libopflex/ofcore/OFFramework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ void OFFramework::setPrrTimerDuration(const uint64_t duration) {
pimpl->processor.setPrrTimerDuration(duration);
}

void OFFramework::setPolicyRetryDelayTimerDuration(const uint64_t duration) {
pimpl->processor.setRetryDelay(duration);
}

void OFFramework::setHandshakeTimeout(const uint32_t timeout) {
pimpl->processor.setHandshakeTimeout(timeout);
}
Expand Down

0 comments on commit ac6b294

Please sign in to comment.