diff --git a/awx/api/views/organization.py b/awx/api/views/organization.py index c86306e9cd..de5ef998cd 100644 --- a/awx/api/views/organization.py +++ b/awx/api/views/organization.py @@ -181,27 +181,18 @@ class OrganizationNotificationTemplatesAnyList(SubListCreateAttachDetachAPIView) relationship = 'notification_templates_any' -class OrganizationNotificationTemplatesStartedList(SubListCreateAttachDetachAPIView): +class OrganizationNotificationTemplatesStartedList(OrganizationNotificationTemplatesAnyList): - model = NotificationTemplate - serializer_class = NotificationTemplateSerializer - parent_model = Organization relationship = 'notification_templates_started' -class OrganizationNotificationTemplatesErrorList(SubListCreateAttachDetachAPIView): +class OrganizationNotificationTemplatesErrorList(OrganizationNotificationTemplatesAnyList): - model = NotificationTemplate - serializer_class = NotificationTemplateSerializer - parent_model = Organization relationship = 'notification_templates_error' -class OrganizationNotificationTemplatesSuccessList(SubListCreateAttachDetachAPIView): +class OrganizationNotificationTemplatesSuccessList(OrganizationNotificationTemplatesAnyList): - model = NotificationTemplate - serializer_class = NotificationTemplateSerializer - parent_model = Organization relationship = 'notification_templates_success' diff --git a/awx/main/scheduler/task_manager.py b/awx/main/scheduler/task_manager.py index 2dec7a985e..5532bef89b 100644 --- a/awx/main/scheduler/task_manager.py +++ b/awx/main/scheduler/task_manager.py @@ -193,6 +193,8 @@ class TaskManager(): status_changed = True if status_changed: workflow_job.websocket_emit_status(workflow_job.status) + # Operations whose queries rely on modifications made during the atomic scheduling session + connection.on_commit(lambda: workflow_job.send_notification_templates('succeeded' if workflow_job.status == 'successful' else 'failed')) if workflow_job.spawned_by_workflow: schedule_task_manager() return result @@ -582,10 +584,5 @@ class TaskManager(): logger.debug("Not running scheduler, another task holds lock") return logger.debug("Starting Scheduler") - with task_manager_bulk_reschedule(): - finished_wfjs = self._schedule() - - # Operations whose queries rely on modifications made during the atomic scheduling session - for wfj in WorkflowJob.objects.filter(id__in=finished_wfjs): - wfj.send_notification_templates('succeeded' if wfj.status == 'successful' else 'failed') + self._schedule()