From ffeb030ec4b4e9486d80557f3d8e6f4a7c29b230 Mon Sep 17 00:00:00 2001 From: Adam Harwell Date: Fri, 7 Feb 2020 22:49:26 +0300 Subject: [PATCH] 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 Change-Id: I865445af34bc63b90d965ef5e2c8f9f49aa9c2f3 (cherry picked from commit 005cd1e6a63f226285486a8287ec523e1d73a7ff) --- .../worker/v1/flows/amphora_flows.py | 1 + .../worker/v1/tasks/database_tasks.py | 2 ++ .../worker/v2/flows/amphora_flows.py | 1 + .../worker/v2/tasks/database_tasks.py | 2 ++ .../worker/v1/tasks/test_database_tasks.py | 1 + .../worker/v2/flows/test_amphora_flows.py | 24 ++++++++++++++++++- .../worker/v2/tasks/test_database_tasks.py | 1 + ...loadbalancer-earlier-ab3dddec48b8da96.yaml | 9 +++++++ 8 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/link-amphora-to-loadbalancer-earlier-ab3dddec48b8da96.yaml diff --git a/octavia/controller/worker/v1/flows/amphora_flows.py b/octavia/controller/worker/v1/flows/amphora_flows.py index be041a8071..cec255caab 100644 --- a/octavia/controller/worker/v1/flows/amphora_flows.py +++ b/octavia/controller/worker/v1/flows/amphora_flows.py @@ -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 = ( diff --git a/octavia/controller/worker/v1/tasks/database_tasks.py b/octavia/controller/worker/v1/tasks/database_tasks.py index 28462a51a5..e8fd338eb3 100644 --- a/octavia/controller/worker/v1/tasks/database_tasks.py +++ b/octavia/controller/worker/v1/tasks/database_tasks.py @@ -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) diff --git a/octavia/controller/worker/v2/flows/amphora_flows.py b/octavia/controller/worker/v2/flows/amphora_flows.py index 5693125f75..a983b30213 100644 --- a/octavia/controller/worker/v2/flows/amphora_flows.py +++ b/octavia/controller/worker/v2/flows/amphora_flows.py @@ -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 = ( diff --git a/octavia/controller/worker/v2/tasks/database_tasks.py b/octavia/controller/worker/v2/tasks/database_tasks.py index 0fc12f7cb6..8c70a843fb 100644 --- a/octavia/controller/worker/v2/tasks/database_tasks.py +++ b/octavia/controller/worker/v2/tasks/database_tasks.py @@ -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) diff --git a/octavia/tests/unit/controller/worker/v1/tasks/test_database_tasks.py b/octavia/tests/unit/controller/worker/v1/tasks/test_database_tasks.py index c2ca7301eb..6f2d00bed0 100644 --- a/octavia/tests/unit/controller/worker/v1/tasks/test_database_tasks.py +++ b/octavia/tests/unit/controller/worker/v1/tasks/test_database_tasks.py @@ -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) diff --git a/octavia/tests/unit/controller/worker/v2/flows/test_amphora_flows.py b/octavia/tests/unit/controller/worker/v2/flows/test_amphora_flows.py index 0996afc9f4..2607f8e856 100644 --- a/octavia/tests/unit/controller/worker/v2/flows/test_amphora_flows.py +++ b/octavia/tests/unit/controller/worker/v2/flows/test_amphora_flows.py @@ -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) diff --git a/octavia/tests/unit/controller/worker/v2/tasks/test_database_tasks.py b/octavia/tests/unit/controller/worker/v2/tasks/test_database_tasks.py index 6ae69e7bd9..2734eb68dc 100644 --- a/octavia/tests/unit/controller/worker/v2/tasks/test_database_tasks.py +++ b/octavia/tests/unit/controller/worker/v2/tasks/test_database_tasks.py @@ -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) diff --git a/releasenotes/notes/link-amphora-to-loadbalancer-earlier-ab3dddec48b8da96.yaml b/releasenotes/notes/link-amphora-to-loadbalancer-earlier-ab3dddec48b8da96.yaml new file mode 100644 index 0000000000..cbb1a58129 --- /dev/null +++ b/releasenotes/notes/link-amphora-to-loadbalancer-earlier-ab3dddec48b8da96.yaml @@ -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.