Handle concurrent implicit L3P creation

In the implicit_policy driver, when creating a default L3 policy,
raise DefaultL3PolicyAlreadyExists if an L3 policy named 'default'
already exists.

If DefaultL3PolicyAlreadyExists is raised when the implicit_policy
driver attempts to create the default L3 policy for a tenant, query
again to see if a default L3 policy has been concurrently created, and
if so, use that. This requires adding local_api wrappers for
postcommit group policy resource CRUD operations called in the
implicit_policy driver, so that clean DB sessions are used.

Also, fix the resource_mapping driver's
delete_policy_target_group_postcommit to gracefully handle partially
constructed states, such as a null L2 policy or a subnet not attached
to a router.

Closes-bug: 1462024
Partial-bug: 1417312

Change-Id: I09f29eef22edb45290070aae30e97c93c77ea341
This commit is contained in:
Robert Kukura
2015-09-16 14:50:26 -04:00
parent 3becb34638
commit 7acac86b65
5 changed files with 232 additions and 98 deletions

View File

@@ -186,9 +186,14 @@ class ImplicitSubnetNotSupported(GroupPolicyBadRequest):
message = _("RMD doesn't support implicit external subnet creation.")
class DefaultL3PolicyAlreadyExists(GroupPolicyBadRequest):
message = _("Default L3 Policy with name %(l3p_name)s already "
"exists and is visible for this tenant.")
class DefaultExternalSegmentAlreadyExists(GroupPolicyBadRequest):
message = _("Default External Segment with name %(es_name)s already "
"exists and is visible for this tenant")
"exists and is visible for this tenant.")
class InvalidCrossTenantReference(GroupPolicyBadRequest):