Handle listener not found during loadbalancer status update
If a call to update loadbalancer status cannot find the specified listener, the API server will throw an exception: "Error while updating the load balancer status: 'NoneType' object has no attribute 'update'" Change ListenerRepository.update() to check the DB query returned a record, and if not, raise a NotFound exception back to the caller. Change-Id: I6693be3e2d2f0e34f19f07f55b0429f8fda317b2 Task: 41108 Story: 2008254
This commit is contained in:
parent
71440bdbdb
commit
17ae2625da
@ -1148,6 +1148,9 @@ class ListenerRepository(BaseRepository):
|
||||
resource.tags = tags
|
||||
listener_db = session.query(self.model_class).filter_by(
|
||||
id=id).first()
|
||||
if not listener_db:
|
||||
raise exceptions.NotFound(
|
||||
resource=data_models.Listener._name(), id=id)
|
||||
# Verify any newly specified default_pool_id exists
|
||||
default_pool_id = model_kwargs.get('default_pool_id')
|
||||
if default_pool_id:
|
||||
|
@ -2952,6 +2952,10 @@ class TestListenerRepositoryTest(BaseRepositoryTest):
|
||||
new_listener = self.listener_repo.get(self.session, id=listener.id)
|
||||
self.assertIn(container1_dm, new_listener.sni_containers)
|
||||
|
||||
def test_update_bad_id(self):
|
||||
self.assertRaises(exceptions.NotFound, self.listener_repo.update,
|
||||
self.session, id=uuidutils.generate_uuid())
|
||||
|
||||
def test_delete(self):
|
||||
listener = self.create_listener(self.FAKE_UUID_1, 80)
|
||||
self.listener_repo.delete(self.session, id=listener.id)
|
||||
|
Loading…
Reference in New Issue
Block a user