Skip to content

Commit c91ffe0

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Fix Amphora Configure API call"
2 parents 7261730 + e756866 commit c91ffe0

File tree

3 files changed

+23
-27
lines changed

3 files changed

+23
-27
lines changed

octavia/db/repositories.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,23 +1244,22 @@ def get_lb_for_amphora(session, amphora_id):
12441244
:param amphora_id: The amphora id to list the load balancers from
12451245
:returns: [octavia.common.data_model]
12461246
"""
1247-
with session.begin():
1248-
db_lb = (
1249-
# Get LB records
1250-
session.query(models.LoadBalancer)
1251-
# Joined to amphora records
1252-
.filter(models.LoadBalancer.id ==
1253-
models.Amphora.load_balancer_id)
1254-
# For just this amphora
1255-
.filter(models.Amphora.id == amphora_id)
1256-
# Where the amphora is not DELETED
1257-
.filter(models.Amphora.status != consts.DELETED)
1258-
# And the LB is also not DELETED
1259-
.filter(models.LoadBalancer.provisioning_status !=
1260-
consts.DELETED)).first()
1261-
if db_lb:
1262-
return db_lb.to_data_model()
1263-
return None
1247+
db_lb = (
1248+
# Get LB records
1249+
session.query(models.LoadBalancer)
1250+
# Joined to amphora records
1251+
.filter(models.LoadBalancer.id ==
1252+
models.Amphora.load_balancer_id)
1253+
# For just this amphora
1254+
.filter(models.Amphora.id == amphora_id)
1255+
# Where the amphora is not DELETED
1256+
.filter(models.Amphora.status != consts.DELETED)
1257+
# And the LB is also not DELETED
1258+
.filter(models.LoadBalancer.provisioning_status !=
1259+
consts.DELETED)).first()
1260+
if db_lb:
1261+
return db_lb.to_data_model()
1262+
return None
12641263

12651264
def get_cert_expiring_amphora(self, session):
12661265
"""Retrieves an amphora whose cert is close to expiring..

octavia/tests/functional/db/test_repositories.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3721,21 +3721,12 @@ def test_allocate_and_associate(self):
37213721
self.assertIsInstance(new_amphora, data_models.Amphora)
37223722

37233723
def test_get_lb_for_amphora(self):
3724-
# TODO(bzhao) this test will raise error as there are more than 64
3725-
# tables in a Join statement in sqlite env. This is a new issue when
3726-
# we introduce resources tags and client certificates, both of them
3727-
# are 1:1 relationship. But we can image that if we have many
3728-
# associated loadbalancer subresources, such as listeners, pools,
3729-
# members and l7 resources. Even though, we don't have tags and
3730-
# client certificates features, we will still hit this issue in
3731-
# sqlite env.
3732-
self.skipTest("No idea how this should work yet")
37333724
amphora = self.create_amphora(self.FAKE_UUID_1)
37343725
self.amphora_repo.associate(self.session, self.lb.id, amphora.id)
37353726
self.session.commit()
37363727
lb = self.amphora_repo.get_lb_for_amphora(self.session, amphora.id)
37373728
self.assertIsNotNone(lb)
3738-
self.assertEqual(self.lb, lb)
3729+
self.assertEqual(self.lb.id, lb.id)
37393730

37403731
def test_get_all_deleted_expiring_amphora(self):
37413732
exp_age = datetime.timedelta(seconds=self.FAKE_EXP_AGE)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
fixes:
3+
- |
4+
Fixed a bug that prevented the amphora from being updated by the Amphora
5+
Configure API call, the API call was succesfull but the internal flow for
6+
updating it failed.

0 commit comments

Comments
 (0)