Update the lb_id on an amp earlier if we know it

When we create amphora for specific loadbalancer it would be
good to get info about mapping pair loadbalancer-amphora as
soon as possible.

For example, if admin needs to debug connectivity issues with amphora
VMs - loadbalancer_id won't be set until AmphoraComputeConnectivityWait
task succeeds (which is never for such case) so they have to go to worker
logs to understand which amphora is related to a currently creating
loadbalancer.

Conflicts:
	octavia/tests/unit/controller/worker/v2/flows/test_amphora_flows.py

NOTE(s10): conflict is due to I55d6c1a0b3e6060d6dacc13ee67d87f0219ef7de
not in Train and older stable branches.

Co-Authored-By: Ann Taraday <akamyshnikova@mirantis.com>
Change-Id: I865445af34bc63b90d965ef5e2c8f9f49aa9c2f3
(cherry picked from commit 005cd1e6a6)
This commit is contained in:
Adam Harwell 2020-02-07 22:49:26 +03:00 committed by Vlad Gusev
parent e358637a10
commit ffeb030ec4
8 changed files with 40 additions and 1 deletions

View File

@ -121,6 +121,7 @@ class AmphoraFlows(object):
create_amp_for_lb_subflow = linear_flow.Flow(sf_name)
create_amp_for_lb_subflow.add(database_tasks.CreateAmphoraInDB(
name=sf_name + '-' + constants.CREATE_AMPHORA_INDB,
requires=constants.LOADBALANCER_ID,
provides=constants.AMPHORA_ID))
require_server_group_id_condition = (

View File

@ -95,8 +95,10 @@ class CreateAmphoraInDB(BaseDatabaseTask):
:returns: The created amphora object
"""
loadbalancer_id = kwargs.get("loadbalancer_id", None)
amphora = self.amphora_repo.create(db_apis.get_session(),
id=uuidutils.generate_uuid(),
load_balancer_id=loadbalancer_id,
status=constants.PENDING_CREATE,
cert_busy=False)

View File

@ -121,6 +121,7 @@ class AmphoraFlows(object):
create_amp_for_lb_subflow = linear_flow.Flow(sf_name)
create_amp_for_lb_subflow.add(database_tasks.CreateAmphoraInDB(
name=sf_name + '-' + constants.CREATE_AMPHORA_INDB,
requires=constants.LOADBALANCER_ID,
provides=constants.AMPHORA_ID))
require_server_group_id_condition = (

View File

@ -95,8 +95,10 @@ class CreateAmphoraInDB(BaseDatabaseTask):
:returns: The created amphora object
"""
loadbalancer_id = kwargs.get("loadbalancer_id", None)
amphora = self.amphora_repo.create(db_apis.get_session(),
id=uuidutils.generate_uuid(),
load_balancer_id=loadbalancer_id,
status=constants.PENDING_CREATE,
cert_busy=False)

View File

@ -147,6 +147,7 @@ class TestDatabaseTasks(base.TestCase):
repo.AmphoraRepository.create.assert_called_once_with(
'TEST',
id=AMP_ID,
load_balancer_id=None,
status=constants.PENDING_CREATE,
cert_busy=False)

View File

@ -80,6 +80,8 @@ class TestAmphoraFlows(base.TestCase):
self.assertIsInstance(amp_flow, flow.Flow)
self.assertIn(constants.FLAVOR, amp_flow.requires)
self.assertIn(constants.BUILD_TYPE_PRIORITY, amp_flow.requires)
self.assertIn(constants.LOADBALANCER_ID, amp_flow.requires)
self.assertIn(constants.AMPHORA, amp_flow.provides)
@ -100,6 +102,8 @@ class TestAmphoraFlows(base.TestCase):
self.assertIsInstance(amp_flow, flow.Flow)
self.assertIn(constants.FLAVOR, amp_flow.requires)
self.assertIn(constants.BUILD_TYPE_PRIORITY, amp_flow.requires)
self.assertIn(constants.LOADBALANCER_ID, amp_flow.requires)
self.assertIn(constants.AMPHORA, amp_flow.provides)
@ -121,6 +125,8 @@ class TestAmphoraFlows(base.TestCase):
self.assertIsInstance(amp_flow, flow.Flow)
self.assertIn(constants.FLAVOR, amp_flow.requires)
self.assertIn(constants.BUILD_TYPE_PRIORITY, amp_flow.requires)
self.assertIn(constants.LOADBALANCER_ID, amp_flow.requires)
self.assertIn(constants.AMPHORA, amp_flow.provides)
@ -142,8 +148,14 @@ class TestAmphoraFlows(base.TestCase):
'SOMEPREFIX', constants.ROLE_MASTER)
self.assertIsInstance(amp_flow, flow.Flow)
self.assertIn(constants.AMPHORA_ID, amp_flow.provides)
self.assertIn(constants.FLAVOR, amp_flow.requires)
self.assertIn(constants.BUILD_TYPE_PRIORITY, amp_flow.requires)
self.assertIn(constants.LOADBALANCER_ID, amp_flow.requires)
self.assertIn(constants.SERVER_GROUP_ID, amp_flow.requires)
self.assertIn(constants.AMPHORA, amp_flow.provides)
self.assertIn(constants.AMPHORA_ID, amp_flow.provides)
self.assertIn(constants.COMPUTE_ID, amp_flow.provides)
self.assertIn(constants.COMPUTE_OBJ, amp_flow.provides)
self.assertIn(constants.SERVER_PEM, amp_flow.provides)
@ -161,6 +173,8 @@ class TestAmphoraFlows(base.TestCase):
self.assertIsInstance(amp_flow, flow.Flow)
self.assertIn(constants.FLAVOR, amp_flow.requires)
self.assertIn(constants.BUILD_TYPE_PRIORITY, amp_flow.requires)
self.assertIn(constants.LOADBALANCER_ID, amp_flow.requires)
self.assertIn(constants.AMPHORA, amp_flow.provides)
@ -181,6 +195,8 @@ class TestAmphoraFlows(base.TestCase):
self.assertIsInstance(amp_flow, flow.Flow)
self.assertIn(constants.FLAVOR, amp_flow.requires)
self.assertIn(constants.BUILD_TYPE_PRIORITY, amp_flow.requires)
self.assertIn(constants.LOADBALANCER_ID, amp_flow.requires)
self.assertIn(constants.AMPHORA, amp_flow.provides)
@ -201,6 +217,12 @@ class TestAmphoraFlows(base.TestCase):
'SOMEPREFIX', constants.ROLE_BACKUP)
self.assertIsInstance(amp_flow, flow.Flow)
self.assertIn(constants.FLAVOR, amp_flow.requires)
self.assertIn(constants.BUILD_TYPE_PRIORITY, amp_flow.requires)
self.assertIn(constants.LOADBALANCER_ID, amp_flow.requires)
self.assertIn(constants.SERVER_GROUP_ID, amp_flow.requires)
self.assertIn(constants.AMPHORA_ID, amp_flow.provides)
self.assertIn(constants.SERVER_GROUP_ID, amp_flow.requires)
self.assertIn(constants.COMPUTE_ID, amp_flow.provides)

View File

@ -147,6 +147,7 @@ class TestDatabaseTasks(base.TestCase):
repo.AmphoraRepository.create.assert_called_once_with(
'TEST',
id=AMP_ID,
load_balancer_id=None,
status=constants.PENDING_CREATE,
cert_busy=False)

View File

@ -0,0 +1,9 @@
---
other:
- |
Amphorae that are booting for a specific loadbalancer will now be linked to
that loadbalancer immediately upon creation. Previously this would not
happen until near the end of the process, leaving a gap during booting
during which is was difficult to understand which booting amphora belonged
to which loadbalancer. This was especially problematic when attempting to
troubleshoot loadbalancers that entered ERROR status due to boot issues.