Merge "Fix Amphora Configure API call"

This commit is contained in:
Zuul 2023-10-17 19:02:41 +00:00 committed by Gerrit Code Review
commit c91ffe0e49
3 changed files with 23 additions and 27 deletions

View File

@ -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..

View File

@ -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)

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.