Browse Source

Merge "Agent liveness - allow time to propagate checks" into stable/train

changes/31/702831/16
Zuul 2 years ago
committed by Gerrit Code Review
parent
commit
844540e2d0
  1. 4
      networking_ovn/ml2/mech_driver.py
  2. 15
      networking_ovn/tests/unit/ml2/test_mech_driver.py

4
networking_ovn/ml2/mech_driver.py

@ -964,7 +964,9 @@ class OVNMechanismDriver(api.MechanismDriver):
except KeyError:
updated_at = timeutils.utcnow(with_timezone=True)
if self._nb_ovn.nb_global.nb_cfg == nb_cfg:
# Allow a maximum of 1 difference between expected and read values
# to avoid false positives.
if self._nb_ovn.nb_global.nb_cfg - nb_cfg <= 1:
# update the time of our successful check
value = timeutils.utcnow(with_timezone=True).isoformat()
self._sb_ovn.db_set('Chassis', chassis.uuid,

15
networking_ovn/tests/unit/ml2/test_mech_driver.py

@ -1547,11 +1547,22 @@ class TestOVNMechanismDriver(test_plugin.Ml2PluginV2TestCase):
chassis = self._add_chassis_agent(5, agent_type)
self.assertTrue(self.mech_driver.agent_alive(chassis, agent_type))
def test_agent_alive_true_one_diff(self):
# Agent should be reported as alive when the nb_cfg delta is 1
# even if the last update time was old enough.
for agent_type in (ovn_const.OVN_CONTROLLER_AGENT,
ovn_const.OVN_METADATA_AGENT):
self.mech_driver._nb_ovn.nb_global.nb_cfg = 5
now = timeutils.utcnow()
updated_at = now - datetime.timedelta(cfg.CONF.agent_down_time + 1)
chassis = self._add_chassis_agent(4, agent_type, updated_at)
self.assertTrue(self.mech_driver.agent_alive(chassis, agent_type))
def test_agent_alive_not_timed_out(self):
for agent_type in (ovn_const.OVN_CONTROLLER_AGENT,
ovn_const.OVN_METADATA_AGENT):
self.mech_driver._nb_ovn.nb_global.nb_cfg = 5
chassis = self._add_chassis_agent(4, agent_type)
chassis = self._add_chassis_agent(3, agent_type)
self.assertTrue(self.mech_driver.agent_alive(chassis, agent_type),
"Agent type %s is not alive" % agent_type)
@ -1561,7 +1572,7 @@ class TestOVNMechanismDriver(test_plugin.Ml2PluginV2TestCase):
self.mech_driver._nb_ovn.nb_global.nb_cfg = 5
now = timeutils.utcnow()
updated_at = now - datetime.timedelta(cfg.CONF.agent_down_time + 1)
chassis = self._add_chassis_agent(4, agent_type, updated_at)
chassis = self._add_chassis_agent(3, agent_type, updated_at)
self.assertFalse(self.mech_driver.agent_alive(chassis, agent_type))
def _test__update_dnat_entry_if_needed(self, up=True):

Loading…
Cancel
Save