Signal to conductor service to apply patch accelerator requests.

Remove `#TODO` for arq patch API operating DB directly.
Use Cyborg conductor service connect with DB to patch arq resoruces.

Change-Id: I97a18eaeb76b3a792c93a5a5c9a02675aa308bdd
Story: 2006187
Task: 35719
This commit is contained in:
songwenping 2020-09-15 10:43:29 +08:00
parent 58be956842
commit 1a45115e2b
4 changed files with 24 additions and 4 deletions

View File

@ -344,5 +344,5 @@ class ARQsController(base.CyborgController):
if patch[0]['op'] == 'add':
self._check_if_already_bound(context, valid_fields)
# TODO(Sundar) Defer to conductor and do all concurently.
objects.ExtARQ.apply_patch(context, patch_list, valid_fields)
pecan.request.conductor_api.arq_apply_patch(
context, patch_list, valid_fields)

View File

@ -97,6 +97,15 @@ class ConductorManager(object):
"""
ExtARQ.delete_by_instance(context, instance)
def arq_apply_patch(self, context, patch_list, valid_fields):
"""Signal to conductor service to apply patch accelerator requests.
:param context: request context.
:param patch_list: A map from ARQ UUIDs to their JSON patches
:param valid_fields: Dict of valid fields
"""
ExtARQ.apply_patch(context, patch_list, valid_fields)
def report_data(self, context, hostname, driver_device_list):
"""Update the Cyborg DB in one hostname according to the
discovered device list.

View File

@ -107,3 +107,14 @@ class ConductorAPI(object):
"""
cctxt = self.client.prepare(topic=self.topic)
cctxt.call(context, 'arq_delete_by_instance_uuid', instance=instance)
def arq_apply_patch(self, context, patch_list, valid_fields):
"""Signal to conductor service to apply patch accelerator requests.
:param context: request context.
:param patch_list: A map from ARQ UUIDs to their JSON patches
:param valid_fields: Dict of valid fields
"""
cctxt = self.client.prepare(topic=self.topic)
return cctxt.call(context, 'arq_apply_patch', patch_list=patch_list,
valid_fields=valid_fields)

View File

@ -254,7 +254,7 @@ class TestARQsController(v2_test.APITestV2):
self.assertIn("Bad response: 403 Forbidden", exc.args[0])
@mock.patch.object(arqs.ARQsController, '_check_if_already_bound')
@mock.patch('cyborg.objects.ExtARQ.apply_patch')
@mock.patch('cyborg.conductor.rpcapi.ConductorAPI.arq_apply_patch')
def test_apply_patch(self, mock_apply_patch, mock_check_if_bound):
"""Test the happy path."""
patch_list, device_rp_uuid = fake_extarq.get_patch_list()
@ -275,7 +275,7 @@ class TestARQsController(v2_test.APITestV2):
mock_check_if_bound.assert_called_once_with(mock.ANY, valid_fields)
@mock.patch.object(arqs.ARQsController, '_check_if_already_bound')
@mock.patch('cyborg.objects.ExtARQ.apply_patch')
@mock.patch('cyborg.conductor.rpcapi.ConductorAPI.arq_apply_patch')
def test_apply_patch_allow_project_id(
self, mock_apply_patch, mock_check_if_bound):
patch_list, _ = fake_extarq.get_patch_list()