Browse Source

Merge "Add amphora delete support to amphorav2 driver"

tags/7.0.0.0rc1
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
b3a1d32b9f
4 changed files with 48 additions and 6 deletions
  1. +4
    -0
      octavia/controller/queue/v2/endpoints.py
  2. +12
    -6
      octavia/controller/worker/v2/controller_worker.py
  3. +5
    -0
      octavia/tests/unit/controller/queue/v2/test_endpoints.py
  4. +27
    -0
      octavia/tests/unit/controller/worker/v2/test_controller_worker.py

+ 4
- 0
octavia/controller/queue/v2/endpoints.py View File

@@ -168,3 +168,7 @@ class Endpoints(object):
LOG.info('Updating amphora \'%s\' agent configuration...',
amphora_id)
self.worker.update_amphora_agent_config(amphora_id)

def delete_amphora(self, context, amphora_id):
LOG.info('Deleting amphora \'%s\'...', amphora_id)
self.worker.delete_amphora(amphora_id)

+ 12
- 6
octavia/controller/worker/v2/controller_worker.py View File

@@ -137,12 +137,18 @@ class ControllerWorker(object):
:returns: None
:raises AmphoraNotFound: The referenced Amphora was not found
"""
amphora = self._amphora_repo.get(db_apis.get_session(),
id=amphora_id)
store = {constants.AMPHORA: amphora.to_dict()}
self.run_flow(
flow_utils.get_delete_amphora_flow,
store=store)
try:
amphora = self._amphora_repo.get(db_apis.get_session(),
id=amphora_id)
store = {constants.AMPHORA: amphora.to_dict()}
self.run_flow(
flow_utils.get_delete_amphora_flow,
store=store)
except Exception as e:
LOG.error('Failed to delete a amphora {0} due to: {1}'.format(
amphora_id, str(e)))
return
LOG.info('Finished deleting amphora %s.', amphora_id)

@tenacity.retry(
retry=tenacity.retry_if_exception_type(db_exceptions.NoResultFound),


+ 5
- 0
octavia/tests/unit/controller/queue/v2/test_endpoints.py View File

@@ -189,3 +189,8 @@ class TestEndpoints(base.TestCase):
self.ep.update_amphora_agent_config(self.context, self.resource)
self.ep.worker.update_amphora_agent_config.assert_called_once_with(
self.resource)

def test_delete_amphora(self):
self.ep.delete_amphora(self.context, self.resource_id)
self.ep.worker.delete_amphora.assert_called_once_with(
self.resource_id)

+ 27
- 0
octavia/tests/unit/controller/worker/v2/test_controller_worker.py View File

@@ -197,6 +197,33 @@ class TestControllerWorker(base.TestCase):
constants.SERVER_GROUP_ID: None,
constants.AVAILABILITY_ZONE: None}))

@mock.patch('octavia.controller.worker.v2.flows.'
'amphora_flows.AmphoraFlows.get_delete_amphora_flow',
return_value='TEST')
def test_delete_amphora(self,
mock_get_delete_amp_flow,
mock_api_get_session,
mock_dyn_log_listener,
mock_taskflow_load,
mock_pool_repo_get,
mock_member_repo_get,
mock_l7rule_repo_get,
mock_l7policy_repo_get,
mock_listener_repo_get,
mock_lb_repo_get,
mock_health_mon_repo_get,
mock_amp_repo_get):

_flow_mock.reset_mock()

cw = controller_worker.ControllerWorker()
cw.delete_amphora(AMP_ID)

(cw.services_controller.run_poster.
assert_called_once_with(
flow_utils.get_delete_amphora_flow,
store={constants.AMPHORA: _db_amphora_mock.to_dict()}))

@mock.patch('octavia.db.repositories.AvailabilityZoneRepository.'
'get_availability_zone_metadata_dict')
@mock.patch('octavia.controller.worker.v2.flows.'


Loading…
Cancel
Save