1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

avoid a race condition in recording deletions in the activity stream

1. You delete something.
2. A signal is generated to record an activity stream deletion.
3. The process of deleting that activity stream deletion attempts to
   look up a related field which has been deleted (in the meantime) via
   a cascade.

see: #6721
see: #7022
This commit is contained in:
Ryan Petrello 2017-07-12 16:38:05 -04:00
parent e6c004babb
commit 80224b791d

View File

@ -21,6 +21,7 @@ import tempfile
from decorator import decorator
# Django
from django.core.exceptions import ObjectDoesNotExist
from django.utils.translation import ugettext_lazy as _
from django.db.models.fields.related import ForeignObjectRel, ManyToManyField
@ -354,7 +355,10 @@ def model_to_dict(obj, serializer_mapping=None):
for field in obj._meta.fields:
if field.name not in allowed_fields:
continue
attr_d[field.name] = _convert_model_field_for_display(obj, field.name, password_fields=password_fields)
try:
attr_d[field.name] = _convert_model_field_for_display(obj, field.name, password_fields=password_fields)
except ObjectDoesNotExist:
logger.warn(_('%s no longer exists for %s') % (field.name, obj))
return attr_d