Do not retry default security group creation

No need to retry creation of a default security group - it will
always fail with DBDuplicate.
The patch opens a transaction before calling to create_security_group()
when creating default security group, thus avoiding db retries.

Closes-Bug: #1625557
Change-Id: Id15b55b097641325ac68275fe4bb3ebe93718cdd
This commit is contained in:
Oleg Bondarev 2016-09-21 10:36:05 +03:00
parent a0d1487cda
commit 09d1185d24
1 changed files with 5 additions and 2 deletions

View File

@ -671,8 +671,11 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase):
'tenant_id': tenant_id,
'description': _('Default security group')}
}
return self.create_security_group(
context, security_group, default_sg=True)['id']
# starting a transaction before create to avoid db retries
with context.session.begin(subtransactions=True):
sg_id = self.create_security_group(
context, security_group, default_sg=True)['id']
return sg_id
def _get_security_groups_on_port(self, context, port):
"""Check that all security groups on port belong to tenant.