mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 11:25:08 -02:30
Add check for no-op case back, remove redundant on_commit code
This commit is contained in:
@@ -242,15 +242,16 @@ class JobNotificationMixin(object):
|
|||||||
else:
|
else:
|
||||||
notification_template_type = 'error'
|
notification_template_type = 'error'
|
||||||
all_notification_templates = set(notification_templates.get(notification_template_type, []))
|
all_notification_templates = set(notification_templates.get(notification_template_type, []))
|
||||||
if status_str != 'running':
|
if len(all_notification_templates):
|
||||||
all_notification_templates.update(notification_templates.get('any', []))
|
if status_str != 'running':
|
||||||
try:
|
all_notification_templates.update(notification_templates.get('any', []))
|
||||||
(notification_subject, notification_body) = getattr(self, 'build_notification_%s_message' % status_str)()
|
try:
|
||||||
except AttributeError:
|
(notification_subject, notification_body) = getattr(self, 'build_notification_%s_message' % status_str)()
|
||||||
raise NotImplementedError("build_notification_%s_message() does not exist" % status_str)
|
except AttributeError:
|
||||||
|
raise NotImplementedError("build_notification_%s_message() does not exist" % status_str)
|
||||||
|
|
||||||
def send_it():
|
def send_it():
|
||||||
send_notifications.delay([n.generate_notification(notification_subject, notification_body).id
|
send_notifications.delay([n.generate_notification(notification_subject, notification_body).id
|
||||||
for n in all_notification_templates],
|
for n in all_notification_templates],
|
||||||
job_id=self.id)
|
job_id=self.id)
|
||||||
connection.on_commit(send_it)
|
connection.on_commit(send_it)
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ class TaskManager():
|
|||||||
if status_changed:
|
if status_changed:
|
||||||
workflow_job.websocket_emit_status(workflow_job.status)
|
workflow_job.websocket_emit_status(workflow_job.status)
|
||||||
# Operations whose queries rely on modifications made during the atomic scheduling session
|
# 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'))
|
workflow_job.send_notification_templates('succeeded' if workflow_job.status == 'successful' else 'failed')
|
||||||
if workflow_job.spawned_by_workflow:
|
if workflow_job.spawned_by_workflow:
|
||||||
schedule_task_manager()
|
schedule_task_manager()
|
||||||
return result
|
return result
|
||||||
@@ -235,7 +235,7 @@ class TaskManager():
|
|||||||
else:
|
else:
|
||||||
if type(task) is WorkflowJob:
|
if type(task) is WorkflowJob:
|
||||||
task.status = 'running'
|
task.status = 'running'
|
||||||
connection.on_commit(lambda: task.send_notification_templates('running'))
|
task.send_notification_templates('running')
|
||||||
logger.debug('Transitioning %s to running status.', task.log_format)
|
logger.debug('Transitioning %s to running status.', task.log_format)
|
||||||
schedule_task_manager()
|
schedule_task_manager()
|
||||||
elif not task.supports_isolation() and rampart_group.controller_id:
|
elif not task.supports_isolation() and rampart_group.controller_id:
|
||||||
|
|||||||
Reference in New Issue
Block a user