}
if obj_type not in model_mapping:
raise q_exc.Invalid(_('Unknown object type: %s') % obj_type)
- elif obj_type == 'health_monitor':
- self.plugin.update_pool_health_monitor(
- context, obj_id['monitor_id'], obj_id['pool_id'], status)
- else:
- self.plugin.update_status(
- context, model_mapping[obj_type], obj_id, status)
+ try:
+ if obj_type == 'health_monitor':
+ self.plugin.update_pool_health_monitor(
+ context, obj_id['monitor_id'], obj_id['pool_id'], status)
+ else:
+ self.plugin.update_status(
+ context, model_mapping[obj_type], obj_id, status)
+ except q_exc.NotFound:
+ # update_status may come from agent on an object which was
+ # already deleted from db with other request
+ LOG.warning(_('Cannot update status: %(obj_type)s %(obj_id)s '
+ 'not found in the DB, it was probably deleted '
+ 'concurrently'),
+ {'obj_type': obj_type, 'obj_id': obj_id})
def pool_destroyed(self, context, pool_id=None):
"""Agent confirmation hook that a pool has been destroyed.
from neutron import context
from neutron.db.loadbalancer import loadbalancer_db as ldb
from neutron.db import servicetype_db as st_db
+from neutron.extensions import loadbalancer
from neutron.extensions import portbindings
from neutron import manager
from neutron.openstack.common import uuidutils
p = self.plugin_instance.get_pool(ctx, pool_id)
self.assertEqual('ACTIVE', p['status'])
+ def test_update_status_pool_deleted_already(self):
+ with mock.patch.object(plugin_driver, 'LOG') as mock_log:
+ pool_id = 'deleted_pool'
+ ctx = context.get_admin_context()
+ self.assertRaises(loadbalancer.PoolNotFound,
+ self.plugin_instance.get_pool, ctx, pool_id)
+ self.callbacks.update_status(ctx, 'pool', pool_id, 'ACTIVE')
+ self.assertTrue(mock_log.warning.called)
+
def test_update_status_health_monitor(self):
with contextlib.nested(
self.pool(),