Merge "LBaaS: handle NotFound exceptions in update_status callback"
This commit is contained in:
commit
bd550f0df1
@ -166,12 +166,20 @@ class LoadBalancerCallbacks(object):
|
|||||||
}
|
}
|
||||||
if obj_type not in model_mapping:
|
if obj_type not in model_mapping:
|
||||||
raise q_exc.Invalid(_('Unknown object type: %s') % obj_type)
|
raise q_exc.Invalid(_('Unknown object type: %s') % obj_type)
|
||||||
elif obj_type == 'health_monitor':
|
try:
|
||||||
self.plugin.update_pool_health_monitor(
|
if obj_type == 'health_monitor':
|
||||||
context, obj_id['monitor_id'], obj_id['pool_id'], status)
|
self.plugin.update_pool_health_monitor(
|
||||||
else:
|
context, obj_id['monitor_id'], obj_id['pool_id'], status)
|
||||||
self.plugin.update_status(
|
else:
|
||||||
context, model_mapping[obj_type], obj_id, status)
|
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):
|
def pool_destroyed(self, context, pool_id=None):
|
||||||
"""Agent confirmation hook that a pool has been destroyed.
|
"""Agent confirmation hook that a pool has been destroyed.
|
||||||
|
@ -25,6 +25,7 @@ from neutron.common import exceptions
|
|||||||
from neutron import context
|
from neutron import context
|
||||||
from neutron.db.loadbalancer import loadbalancer_db as ldb
|
from neutron.db.loadbalancer import loadbalancer_db as ldb
|
||||||
from neutron.db import servicetype_db as st_db
|
from neutron.db import servicetype_db as st_db
|
||||||
|
from neutron.extensions import loadbalancer
|
||||||
from neutron.extensions import portbindings
|
from neutron.extensions import portbindings
|
||||||
from neutron import manager
|
from neutron import manager
|
||||||
from neutron.openstack.common import uuidutils
|
from neutron.openstack.common import uuidutils
|
||||||
@ -350,6 +351,15 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase):
|
|||||||
p = self.plugin_instance.get_pool(ctx, pool_id)
|
p = self.plugin_instance.get_pool(ctx, pool_id)
|
||||||
self.assertEqual('ACTIVE', p['status'])
|
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):
|
def test_update_status_health_monitor(self):
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
self.pool(),
|
self.pool(),
|
||||||
|
Loading…
Reference in New Issue
Block a user