Skip to content

Commit

Permalink
Using revision_number to ensure no overlap in *one* network
Browse files Browse the repository at this point in the history
This patch uses revision_number in database. When creating
a subnet in a network, the revision_number of the network
will be increased. That will prevent overlapping CIDR
(overlapping CIDR means some subnets' cidrs are overlapping)
on *one* network.

Basically, in case of concurrent requests creating subnets
on *one* network, only one request successes, other requests
needs retrying request.

Change-Id: Id6548535075bed87a4b36e1462db546ab9163f29
Closes-Bug: #1532695
  • Loading branch information
namnh68 committed Aug 24, 2016
1 parent 14ebfb5 commit 5264ab9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions neutron/db/models_v2.py
Expand Up @@ -196,6 +196,7 @@ class Subnet(model_base.HasStandardAttributes, model_base.BASEV2,
ip_version = sa.Column(sa.Integer, nullable=False)
cidr = sa.Column(sa.String(64), nullable=False)
gateway_ip = sa.Column(sa.String(64))
revises_on_change = ('networks', )
allocation_pools = orm.relationship(IPAllocationPool,
backref='subnet',
lazy="joined",
Expand Down
11 changes: 11 additions & 0 deletions neutron/tests/tempest/api/test_revisions.py
Expand Up @@ -55,6 +55,17 @@ def test_update_subnetpool_bumps_revision(self):
updated = self.admin_client.update_subnetpool(sp['id'], name='sp2')
self.assertGreater(updated['subnetpool']['revision'], sp['revision'])

@test.idempotent_id('e8c5d7db-2b8d-4567-a326-6e123437c4d1')
def test_update_subnet_bumps_network_revision(self):
net = self.create_network()
subnet = self.create_subnet(net)
updated = self.client.show_network(net['id'])
self.assertGreater(updated['network']['revision'], net['revision'])
self.client.delete_subnet(subnet['id'])
updated2 = self.client.show_network(net['id'])
self.assertGreater(updated2['network']['revision'],
updated['network']['revision'])

@test.idempotent_id('6c256f71-c929-4200-b3dc-4e1843506be5')
@test.requires_ext(extension="security-group", service="network")
def test_update_sg_group_bumps_revision(self):
Expand Down

0 comments on commit 5264ab9

Please sign in to comment.