Fix fully-populated API with allowed_cidrs

When creating a LB + a listener with an allowed_cidr with the
fully-populated API, an issue happened when Octavia validated that the
allowed_cidrs and the VIP ip address have the same IP version. The
vip.ip_address value was not updated in the load balancer object,
forcing the expiration of the DB object before entering _graph_create
fixes this issue.

Note: there's no change in the tests, the test function for this feature
exists, looks correct, and passes successfully, the bug is only
reproducible in octavia-api.

Closes-Bug: 2057751
Change-Id: Ia106d81c1b2588e5d938d2238c8a2f6660bf5ef1
(cherry picked from commit 5d9b23c602)
This commit is contained in:
Gregory Thiemonge 2024-03-13 04:31:17 -04:00
parent 41e7707645
commit d943336c0e
2 changed files with 14 additions and 0 deletions

View File

@ -546,6 +546,13 @@ class LoadBalancersController(base.BaseController):
subnet_id=add_vip.subnet_id)
if listeners or pools:
# expire_all is required here, it ensures that the loadbalancer
# will be re-fetched with its associated vip in _graph_create.
# without expire_all the vip attributes that have been updated
# just before this call may not be set correctly in the
# loadbalancer object.
lock_session.expire_all()
db_pools, db_lists = self._graph_create(
context.session, lock_session, db_lb, listeners, pools)

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixed a bug when creating a load balancer and a listener with
``allowed_cidrs`` with the fully-populated load balancer API, the call was
rejected because Octavia could not validate that the IP addresses of the
``allowed_cidrs`` have the same family as the VIP address.