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:
parent
8b275c9703
commit
e756866a7b
@ -1244,23 +1244,22 @@ class AmphoraRepository(BaseRepository):
|
||||
:param amphora_id: The amphora id to list the load balancers from
|
||||
:returns: [octavia.common.data_model]
|
||||
"""
|
||||
with session.begin():
|
||||
db_lb = (
|
||||
# Get LB records
|
||||
session.query(models.LoadBalancer)
|
||||
# Joined to amphora records
|
||||
.filter(models.LoadBalancer.id ==
|
||||
models.Amphora.load_balancer_id)
|
||||
# For just this amphora
|
||||
.filter(models.Amphora.id == amphora_id)
|
||||
# Where the amphora is not DELETED
|
||||
.filter(models.Amphora.status != consts.DELETED)
|
||||
# And the LB is also not DELETED
|
||||
.filter(models.LoadBalancer.provisioning_status !=
|
||||
consts.DELETED)).first()
|
||||
if db_lb:
|
||||
return db_lb.to_data_model()
|
||||
return None
|
||||
db_lb = (
|
||||
# Get LB records
|
||||
session.query(models.LoadBalancer)
|
||||
# Joined to amphora records
|
||||
.filter(models.LoadBalancer.id ==
|
||||
models.Amphora.load_balancer_id)
|
||||
# For just this amphora
|
||||
.filter(models.Amphora.id == amphora_id)
|
||||
# Where the amphora is not DELETED
|
||||
.filter(models.Amphora.status != consts.DELETED)
|
||||
# And the LB is also not DELETED
|
||||
.filter(models.LoadBalancer.provisioning_status !=
|
||||
consts.DELETED)).first()
|
||||
if db_lb:
|
||||
return db_lb.to_data_model()
|
||||
return None
|
||||
|
||||
def get_cert_expiring_amphora(self, session):
|
||||
"""Retrieves an amphora whose cert is close to expiring..
|
||||
|
@ -3721,21 +3721,12 @@ class AmphoraRepositoryTest(BaseRepositoryTest):
|
||||
self.assertIsInstance(new_amphora, data_models.Amphora)
|
||||
|
||||
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)
|
||||
self.amphora_repo.associate(self.session, self.lb.id, amphora.id)
|
||||
self.session.commit()
|
||||
lb = self.amphora_repo.get_lb_for_amphora(self.session, amphora.id)
|
||||
self.assertIsNotNone(lb)
|
||||
self.assertEqual(self.lb, lb)
|
||||
self.assertEqual(self.lb.id, lb.id)
|
||||
|
||||
def test_get_all_deleted_expiring_amphora(self):
|
||||
exp_age = datetime.timedelta(seconds=self.FAKE_EXP_AGE)
|
||||
|
@ -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.
|
Loading…
Reference in New Issue
Block a user