]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
VMWare NSXv: id fields should be nullable
authorKobi Samoray <ksamoray@vmware.com>
Wed, 18 Feb 2015 17:25:27 +0000 (19:25 +0200)
committerKobi Samoray <ksamoray@vmware.com>
Wed, 18 Feb 2015 17:25:27 +0000 (19:25 +0200)
To handle concurrency issues when two neutron nodes initialize at the same
time, we use the following solution:
- Each neutron node attempts to create a record with id value=NULL
- One which inserts successfully, resumes to create the resource and once
the resource is created, it updates its id in the database
- One which fails with duplicate entry exception, busy-waits until the id
field is populated, of terminates on timeout.

Relevant resources are internal edges, and internal networks.

To implement the above, id fields should be nullable.

Change-Id: Iff94678ab341ccb1310d6b6efc53a52bd3bb9240
Partially-Implements: blueprint vmware-nsx-v

neutron/db/migration/alembic_migrations/versions/4dbe243cd84d_nsxv.py
neutron/plugins/vmware/dbexts/nsxv_models.py

index 3fbb7ea5f89507e4ed9b62c6906fd340f0b32074..6c17bfae635a764c23f76524ea5cb70e55d0e936 100644 (file)
@@ -57,14 +57,14 @@ def upgrade():
         'nsxv_internal_networks',
         sa.Column('network_purpose', internal_network_purpose_enum,
                   nullable=False),
-        sa.Column('network_id', sa.String(length=36), nullable=False),
+        sa.Column('network_id', sa.String(length=36), nullable=True),
         sa.ForeignKeyConstraint(['network_id'], ['networks.id'],
                                 ondelete='CASCADE'),
         sa.PrimaryKeyConstraint('network_purpose'))
     op.create_table(
         'nsxv_internal_edges',
         sa.Column('ext_ip_address', sa.String(length=64), nullable=False),
-        sa.Column('router_id', sa.String(length=36), nullable=False),
+        sa.Column('router_id', sa.String(length=36), nullable=True),
         sa.Column('purpose', internal_edge_purpose_enum, nullable=True),
         sa.PrimaryKeyConstraint('ext_ip_address'))
     op.create_table(
index 369bfa7f3cab620204c0abf601ec086c083d32ac..bac20d8d0b316b65ed0e3ea787c58ea1db534980 100644 (file)
@@ -84,7 +84,7 @@ class NsxvInternalNetworks(model_base.BASEV2):
         primary_key=True)
     network_id = sa.Column(sa.String(36),
                            sa.ForeignKey("networks.id", ondelete="CASCADE"),
-                           nullable=False)
+                           nullable=True)
 
 
 class NsxvInternalEdges(model_base.BASEV2):
@@ -93,7 +93,7 @@ class NsxvInternalEdges(model_base.BASEV2):
     __tablename__ = 'nsxv_internal_edges'
 
     ext_ip_address = sa.Column(sa.String(64), primary_key=True)
-    router_id = sa.Column(sa.String(36), nullable=False)
+    router_id = sa.Column(sa.String(36), nullable=True)
     purpose = sa.Column(
         sa.Enum(nsxv_constants.INTER_EDGE_PURPOSE,
                 name='nsxv_internal_edges_purpose'))