Supress exception with concurrent deletion

Relates https://github.com/ansible/ansible-tower/issues/7768

This issue, as well as
https://github.com/ansible/ansible-tower/issues/7622, both rooted in a
concurrency issue of Django ORM:
https://github.com/ansible/ansible-tower/issues/762://code.djangoproject.com/ticket/28806

The solution related deals specifically with the related issue, but is
not a general solution. A general workaround can be found in
https://github.com/ansible/tower/pull/500.

Signed-off-by: Aaron Tan <jangsutsr@gmail.com>
This commit is contained in:
Aaron Tan
2017-11-16 16:43:21 -05:00
parent e20599d7bb
commit 0641c6b0a6
2 changed files with 57 additions and 17 deletions

View File

@@ -12,6 +12,7 @@ from django.db.models import Q, Prefetch
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext_lazy as _
from django.core.exceptions import ObjectDoesNotExist
# Django REST Framework
from rest_framework.exceptions import ParseError, PermissionDenied, ValidationError
@@ -1134,8 +1135,11 @@ class ProjectUpdateAccess(BaseAccess):
def can_start(self, obj, validate_license=True):
# for relaunching
if obj and obj.project:
return self.user in obj.project.update_role
try:
if obj and obj.project:
return self.user in obj.project.update_role
except ObjectDoesNotExist:
pass
return False
@check_superuser