Allow modification of max retries in OVSNeutronAgent

Use class variable instead of module constant to
allow modification of max_device_retries in classes inheriting
from OVSNeutronAgent.

Closes-Bug: #1952898
Change-Id: I952491ca89466540d39d78f963b581302c0d8a17
This commit is contained in:
Szymon Wroblewski
2021-11-30 13:42:39 +01:00
parent 5116a88f27
commit 0152b43ee1

View File

@@ -144,6 +144,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
# 1.5 Added binding_activate and binding_deactivate
# 1.7 Add support for smartnic ports
target = oslo_messaging.Target(version='1.7')
max_device_retries = constants.MAX_DEVICE_RETRIES
def __init__(self, bridge_classes, ext_manager, conf=None):
'''Constructor.
@@ -2440,12 +2441,11 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
if sync:
LOG.info("Agent out of sync with plugin!")
consecutive_resyncs = consecutive_resyncs + 1
if (consecutive_resyncs >=
constants.MAX_DEVICE_RETRIES):
if consecutive_resyncs >= self.max_device_retries:
LOG.warning(
"Clearing cache of registered ports,"
" retries to resync were > %s",
constants.MAX_DEVICE_RETRIES)
self.max_device_retries)
ports.clear()
ancillary_ports.clear()
consecutive_resyncs = 0
@@ -2521,12 +2521,12 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
devices_not_to_retry = set()
for dev in devices_set:
retries = failed_devices_retries_map.get(dev, 0)
if retries >= constants.MAX_DEVICE_RETRIES:
if retries >= self.max_device_retries:
devices_not_to_retry.add(dev)
LOG.warning(
"Device %(dev)s failed for %(times)s times and won't "
"be retried anymore", {
'dev': dev, 'times': constants.MAX_DEVICE_RETRIES})
'dev': dev, 'times': self.max_device_retries})
else:
new_failed_devices_retries_map[dev] = retries + 1
return devices_not_to_retry