Add a workaround for LP: #2024481

Due to the race condition described in LP: #2024481, before adding
networks to the speaker we need to wait until it gets scheduled,
otherwise it may not advertise some routes that are attempted to be
advertised before the speaker is scheduled to a dragent service causing
a non-fatal service error.
This commit is contained in:
Dmitrii Shcherbakov
2023-06-20 22:16:04 +04:00
parent 35c5fca0c7
commit 4b80d0db76
+21
View File
@@ -19,6 +19,9 @@
import argparse
import logging
import sys
import tenacity
import zaza.model
from zaza.openstack.utilities import (
cli as cli_utils,
openstack as openstack_utils,
@@ -29,6 +32,20 @@ from zaza.openstack.utilities import (
NDR_TEST_FIP = "NDR_TEST_FIP"
@tenacity.retry(wait=tenacity.wait_exponential(multiplier=1, max=60),
reraise=True, stop=tenacity.stop_after_attempt(10))
def _assert_speaker_added(local_as):
logging.debug(f"Checking that a BGP speaker for {local_as} has been added")
# As soon as this message appears in the log on a pristine machine we can
# proceed with adding routes. The check is due to LP: #2024481.
grep_cmd = (f'grep "Added BGP Speaker for local_as={local_as}"'
f' /var/log/neutron/neutron-bgp-dragent.log')
# Usually we only have one unit in test bundles but let's be generic.
for unit in zaza.model.get_units("neutron-dynamic-routing"):
juju_utils.remote_run(unit, fatal=True,
remote_cmd=grep_cmd)
def setup_bgp_speaker(peer_application_name, keystone_session=None):
"""Perform BGP Speaker setup.
@@ -66,6 +83,10 @@ def setup_bgp_speaker(peer_application_name, keystone_session=None):
bgp_speaker = openstack_utils.create_bgp_speaker(
neutron_client, local_as=dr_asn)
# Due to LP: #2024481 make sure the BGP speaker is actually scheduled
# on this unit before adding any networks to it.
_assert_speaker_added(local_as=bgp_speaker["local_as"])
# Add networks to bgp speaker
logging.info("Advertising BGP routes")
openstack_utils.add_network_to_bgp_speaker(