Fixed FlushError on subnet creation retry
Automatically allocated fixed IP addresses were not reflected on cached port records, which triggered FlushError if the allocating method failed and triggered a retry. Change-Id: Ia7725094827b554aa6d928c7daa026959a237991 Closes-Bug: #1706750
This commit is contained in:
parent
1c94a80b55
commit
d207fb9235
|
@ -128,13 +128,6 @@ class DbBasePluginCommon(common_db_mixin.CommonDbMixin):
|
|||
# Ib32509d974c8654131112234bcf19d6eae8f7cca
|
||||
allocated.create()
|
||||
|
||||
# NOTE(kevinbenton): We add this to the session info so the sqlalchemy
|
||||
# object isn't immediately garbage collected. Otherwise when the
|
||||
# fixed_ips relationship is referenced a new persistent object will be
|
||||
# added to the session that will interfere with retry operations.
|
||||
# See bug 1556178 for details.
|
||||
context.session.info.setdefault('allocated_ips', []).append(allocated)
|
||||
|
||||
def _make_subnet_dict(self, subnet, fields=None, context=None):
|
||||
res = {'id': subnet['id'],
|
||||
'name': subnet['name'],
|
||||
|
|
|
@ -382,7 +382,6 @@ class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin):
|
|||
ip['subnet_id'], db_port.id)
|
||||
self._update_db_port(context, db_port, new_port, network_id,
|
||||
new_mac)
|
||||
getattr(db_port, 'fixed_ips') # refresh relationship before return
|
||||
|
||||
if auto_assign_subnets:
|
||||
port_copy = copy.deepcopy(original)
|
||||
|
@ -390,7 +389,8 @@ class IpamPluggableBackend(ipam_backend_mixin.IpamBackendMixin):
|
|||
port_copy['fixed_ips'] = auto_assign_subnets
|
||||
self.allocate_ips_for_port_and_store(context,
|
||||
{'port': port_copy}, port_copy['id'])
|
||||
context.session.refresh(db_port)
|
||||
|
||||
getattr(db_port, 'fixed_ips') # refresh relationship before return
|
||||
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
|
|
Loading…
Reference in New Issue