Example #1
0
def delete_group(group):
    updated = (
        Group.objects.filter(id=group.id)
        .exclude(status__in=[GroupStatus.PENDING_DELETION, GroupStatus.DELETION_IN_PROGRESS])
        .update(status=GroupStatus.PENDING_DELETION)
    )

    if not updated:
        return

    eventstream_state = eventstream.start_delete_groups(group.project_id, [group.id])
    transaction_id = uuid4().hex

    GroupHash.objects.filter(project_id=group.project_id, group__id=group.id).delete()

    delete_groups.apply_async(
        kwargs={
            "object_ids": [group.id],
            "transaction_id": transaction_id,
            "eventstream_state": eventstream_state,
        },
        countdown=3600,
    )

    return transaction_id
def delete_group(group):
    updated = (Group.objects.filter(id=group.id).exclude(status__in=[
        GroupStatus.PENDING_DELETION, GroupStatus.DELETION_IN_PROGRESS
    ]).update(status=GroupStatus.PENDING_DELETION))

    if not updated:
        return

    eventstream_state = eventstream.start_delete_groups(
        group.project_id, [group.id])
    transaction_id = uuid4().hex

    GroupHash.objects.filter(project_id=group.project_id,
                             group__id=group.id).delete()
    # We remove `GroupInbox` rows here so that they don't end up influencing queries for
    # `Group` instances that are pending deletion
    GroupInbox.objects.filter(project_id=group.project.id,
                              group__id=group.id).delete()

    delete_groups.apply_async(
        kwargs={
            "object_ids": [group.id],
            "transaction_id": transaction_id,
            "eventstream_state": eventstream_state,
        },
        countdown=3600,
    )

    return transaction_id
Example #3
0
    def delete(self, request, group):
        """
        Remove an Issue
        ```````````````

        Removes an individual issue.

        :pparam string issue_id: the ID of the issue to delete.
        :auth: required
        """
        from sentry.tasks.deletion import delete_groups

        updated = Group.objects.filter(id=group.id, ).exclude(status__in=[
            GroupStatus.PENDING_DELETION,
            GroupStatus.DELETION_IN_PROGRESS,
        ]).update(status=GroupStatus.PENDING_DELETION)
        if updated:
            project = group.project

            eventstream_state = eventstream.start_delete_groups(
                group.project_id, [group.id])

            GroupHashTombstone.tombstone_groups(
                project_id=project.id,
                group_ids=[group.id],
            )

            transaction_id = uuid4().hex

            delete_groups.apply_async(
                kwargs={
                    'object_ids': [group.id],
                    'transaction_id': transaction_id,
                    'eventstream_state': eventstream_state,
                },
                countdown=3600,
            )

            self.create_audit_entry(
                request=request,
                organization_id=project.organization_id if project else None,
                target_object=group.id,
                transaction_id=transaction_id,
            )

            delete_logger.info('object.delete.queued',
                               extra={
                                   'object_id': group.id,
                                   'transaction_id': transaction_id,
                                   'model': type(group).__name__,
                               })

            issue_deleted.send_robust(group=group,
                                      user=request.user,
                                      delete_type='delete',
                                      sender=self.__class__)

        return Response(status=202)
Example #4
0
def delete_groups(request, project, group_list, delete_type):
    if not group_list:
        return

    # deterministic sort for sanity, and for very large deletions we'll
    # delete the "smaller" groups first
    group_list.sort(key=lambda g: (g.times_seen, g.id))
    group_ids = [g.id for g in group_list]

    Group.objects.filter(
        id__in=group_ids,
    ).exclude(status__in=[
        GroupStatus.PENDING_DELETION,
        GroupStatus.DELETION_IN_PROGRESS,
    ]).update(status=GroupStatus.PENDING_DELETION)

    eventstream_state = eventstream.start_delete_groups(project.id, group_ids)
    transaction_id = uuid4().hex

    GroupHash.objects.filter(
        project_id=project.id,
        group__id__in=group_ids,
    ).delete()

    delete_groups_task.apply_async(
        kwargs={
            'object_ids': group_ids,
            'transaction_id': transaction_id,
            'eventstream_state': eventstream_state,
        },
        countdown=3600,
    )

    for group in group_list:
        create_audit_entry(
            request=request,
            transaction_id=transaction_id,
            logger=audit_logger,
            organization_id=project.organization_id,
            target_object=group.id,
        )

        delete_logger.info(
            'object.delete.queued',
            extra={
                'object_id': group.id,
                'transaction_id': transaction_id,
                'model': type(group).__name__,
            }
        )

        issue_deleted.send_robust(
            group=group,
            user=request.user,
            delete_type=delete_type,
            sender=delete_groups)
Example #5
0
def _delete_groups(request, project, group_list, delete_type):
    if not group_list:
        return

    # deterministic sort for sanity, and for very large deletions we'll
    # delete the "smaller" groups first
    group_list.sort(key=lambda g: (g.times_seen, g.id))
    group_ids = [g.id for g in group_list]

    Group.objects.filter(
        id__in=group_ids,
    ).exclude(status__in=[
        GroupStatus.PENDING_DELETION,
        GroupStatus.DELETION_IN_PROGRESS,
    ]).update(status=GroupStatus.PENDING_DELETION)

    eventstream_state = eventstream.start_delete_groups(project.id, group_ids)
    transaction_id = uuid4().hex

    GroupHash.objects.filter(
        project_id=project.id,
        group__id__in=group_ids,
    ).delete()

    delete_groups_task.apply_async(
        kwargs={
            'object_ids': group_ids,
            'transaction_id': transaction_id,
            'eventstream_state': eventstream_state,
        },
        countdown=3600,
    )

    for group in group_list:
        create_audit_entry(
            request=request,
            transaction_id=transaction_id,
            logger=audit_logger,
            organization_id=project.organization_id,
            target_object=group.id,
        )

        delete_logger.info(
            'object.delete.queued',
            extra={
                'object_id': group.id,
                'transaction_id': transaction_id,
                'model': type(group).__name__,
            }
        )

        issue_deleted.send_robust(
            group=group,
            user=request.user,
            delete_type=delete_type,
            sender=_delete_groups)
def _delete_groups(request, project, group_list, delete_type):
    if not group_list:
        return

    # deterministic sort for sanity, and for very large deletions we'll
    # delete the "smaller" groups first
    group_list.sort(key=lambda g: (g.times_seen, g.id))
    group_ids = [g.id for g in group_list]

    Group.objects.filter(id__in=group_ids).exclude(status__in=[
        GroupStatus.PENDING_DELETION, GroupStatus.DELETION_IN_PROGRESS
    ]).update(status=GroupStatus.PENDING_DELETION)

    eventstream_state = eventstream.start_delete_groups(project.id, group_ids)
    transaction_id = uuid4().hex

    GroupHash.objects.filter(project_id=project.id,
                             group__id__in=group_ids).delete()
    # We remove `GroupInbox` rows here so that they don't end up influencing queries for
    # `Group` instances that are pending deletion
    GroupInbox.objects.filter(project_id=project.id,
                              group__id__in=group_ids).delete()

    delete_groups_task.apply_async(
        kwargs={
            "object_ids": group_ids,
            "transaction_id": transaction_id,
            "eventstream_state": eventstream_state,
        },
        countdown=3600,
    )

    for group in group_list:
        create_audit_entry(
            request=request,
            transaction_id=transaction_id,
            logger=audit_logger,
            organization_id=project.organization_id,
            target_object=group.id,
        )

        delete_logger.info(
            "object.delete.queued",
            extra={
                "object_id": group.id,
                "transaction_id": transaction_id,
                "model": type(group).__name__,
            },
        )

        issue_deleted.send_robust(group=group,
                                  user=request.user,
                                  delete_type=delete_type,
                                  sender=_delete_groups)
Example #7
0
    def _delete_groups(self, request, project, group_list, delete_type):
        if not group_list:
            return

        group_ids = [g.id for g in group_list]

        Group.objects.filter(id__in=group_ids, ).exclude(status__in=[
            GroupStatus.PENDING_DELETION,
            GroupStatus.DELETION_IN_PROGRESS,
        ]).update(status=GroupStatus.PENDING_DELETION)

        eventstream_state = eventstream.start_delete_groups(
            project.id, group_ids)

        GroupHashTombstone.tombstone_groups(
            project_id=project.id,
            group_ids=group_ids,
        )

        transaction_id = uuid4().hex

        delete_groups.apply_async(
            kwargs={
                'object_ids': group_ids,
                'transaction_id': transaction_id,
                'eventstream_state': eventstream_state,
            },
            countdown=3600,
        )

        for group in group_list:
            self.create_audit_entry(
                request=request,
                organization_id=project.organization_id,
                target_object=group.id,
                transaction_id=transaction_id,
            )

            delete_logger.info('object.delete.queued',
                               extra={
                                   'object_id': group.id,
                                   'transaction_id': transaction_id,
                                   'model': type(group).__name__,
                               })

            issue_deleted.send_robust(group=group,
                                      user=request.user,
                                      delete_type=delete_type,
                                      sender=self.__class__)
Example #8
0
    def delete(self, request, group):
        """
        Remove an Issue
        ```````````````

        Removes an individual issue.

        :pparam string issue_id: the ID of the issue to delete.
        :auth: required
        """
        try:
            from sentry.tasks.deletion import delete_groups

            updated = (Group.objects.filter(id=group.id).exclude(status__in=[
                GroupStatus.PENDING_DELETION, GroupStatus.DELETION_IN_PROGRESS
            ]).update(status=GroupStatus.PENDING_DELETION))
            if updated:
                project = group.project

                eventstream_state = eventstream.start_delete_groups(
                    group.project_id, [group.id])
                transaction_id = uuid4().hex

                GroupHash.objects.filter(project_id=group.project_id,
                                         group__id=group.id).delete()

                delete_groups.apply_async(
                    kwargs={
                        "object_ids": [group.id],
                        "transaction_id": transaction_id,
                        "eventstream_state": eventstream_state,
                    },
                    countdown=3600,
                )

                self.create_audit_entry(
                    request=request,
                    organization_id=project.organization_id
                    if project else None,
                    target_object=group.id,
                    transaction_id=transaction_id,
                )

                delete_logger.info(
                    "object.delete.queued",
                    extra={
                        "object_id": group.id,
                        "transaction_id": transaction_id,
                        "model": type(group).__name__,
                    },
                )

                issue_deleted.send_robust(group=group,
                                          user=request.user,
                                          delete_type="delete",
                                          sender=self.__class__)
            metrics.incr("group.update.http_response",
                         sample_rate=1.0,
                         tags={"status": 200})
            return Response(status=202)
        except Exception:
            metrics.incr("group.update.http_response",
                         sample_rate=1.0,
                         tags={"status": 500})
            raise
Example #9
0
    def delete(self, request, group):
        """
        Remove an Issue
        ```````````````

        Removes an individual issue.

        :pparam string issue_id: the ID of the issue to delete.
        :auth: required
        """
        from sentry.tasks.deletion import delete_groups

        updated = Group.objects.filter(
            id=group.id,
        ).exclude(status__in=[
            GroupStatus.PENDING_DELETION,
            GroupStatus.DELETION_IN_PROGRESS,
        ]).update(status=GroupStatus.PENDING_DELETION)
        if updated:
            project = group.project

            eventstream_state = eventstream.start_delete_groups(group.project_id, [group.id])
            transaction_id = uuid4().hex

            GroupHash.objects.filter(
                project_id=group.project_id,
                group__id=group.id,
            ).delete()

            delete_groups.apply_async(
                kwargs={
                    'object_ids': [group.id],
                    'transaction_id': transaction_id,
                    'eventstream_state': eventstream_state,
                },
                countdown=3600,
            )

            self.create_audit_entry(
                request=request,
                organization_id=project.organization_id if project else None,
                target_object=group.id,
                transaction_id=transaction_id,
            )

            delete_logger.info(
                'object.delete.queued',
                extra={
                    'object_id': group.id,
                    'transaction_id': transaction_id,
                    'model': type(group).__name__,
                }
            )

            issue_deleted.send_robust(
                group=group,
                user=request.user,
                delete_type='delete',
                sender=self.__class__)

        return Response(status=202)