Fix Amphora Configure API call

The Amphora Configure API call failed because  a new sqlalchemy
transaction was created but a transaction was already begun.
Remove the nested begin() calls to fix the issue.

Closes-Bug: #2039281
Change-Id: Ie20cce4e8355737711a9def7470550e4e43c0c35
This commit is contained in:
Gregory Thiemonge 2023-10-13 10:19:11 -04:00
parent 8b275c9703
commit e756866a7b
3 changed files with 23 additions and 27 deletions

View File

@ -1244,7 +1244,6 @@ class AmphoraRepository(BaseRepository):
:param amphora_id: The amphora id to list the load balancers from :param amphora_id: The amphora id to list the load balancers from
:returns: [octavia.common.data_model] :returns: [octavia.common.data_model]
""" """
with session.begin():
db_lb = ( db_lb = (
# Get LB records # Get LB records
session.query(models.LoadBalancer) session.query(models.LoadBalancer)

View File

@ -3721,21 +3721,12 @@ class AmphoraRepositoryTest(BaseRepositoryTest):
self.assertIsInstance(new_amphora, data_models.Amphora) self.assertIsInstance(new_amphora, data_models.Amphora)
def test_get_lb_for_amphora(self): def test_get_lb_for_amphora(self):
# TODO(bzhao) this test will raise error as there are more than 64
# tables in a Join statement in sqlite env. This is a new issue when
# we introduce resources tags and client certificates, both of them
# are 1:1 relationship. But we can image that if we have many
# associated loadbalancer subresources, such as listeners, pools,
# members and l7 resources. Even though, we don't have tags and
# client certificates features, we will still hit this issue in
# sqlite env.
self.skipTest("No idea how this should work yet")
amphora = self.create_amphora(self.FAKE_UUID_1) amphora = self.create_amphora(self.FAKE_UUID_1)
self.amphora_repo.associate(self.session, self.lb.id, amphora.id) self.amphora_repo.associate(self.session, self.lb.id, amphora.id)
self.session.commit() self.session.commit()
lb = self.amphora_repo.get_lb_for_amphora(self.session, amphora.id) lb = self.amphora_repo.get_lb_for_amphora(self.session, amphora.id)
self.assertIsNotNone(lb) self.assertIsNotNone(lb)
self.assertEqual(self.lb, lb) self.assertEqual(self.lb.id, lb.id)
def test_get_all_deleted_expiring_amphora(self): def test_get_all_deleted_expiring_amphora(self):
exp_age = datetime.timedelta(seconds=self.FAKE_EXP_AGE) exp_age = datetime.timedelta(seconds=self.FAKE_EXP_AGE)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed a bug that prevented the amphora from being updated by the Amphora
Configure API call, the API call was succesfull but the internal flow for
updating it failed.