mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 03:47:36 -02:30
Emit just one message type for status change events:
This commit is contained in:
@@ -175,7 +175,7 @@ def rebuild_graph(message):
|
|||||||
task.status = 'failed'
|
task.status = 'failed'
|
||||||
task.job_explanation += "Task was marked as running in Tower but was not present in Celery so it has been marked as failed"
|
task.job_explanation += "Task was marked as running in Tower but was not present in Celery so it has been marked as failed"
|
||||||
task.save()
|
task.save()
|
||||||
emit_websocket_notification('/socket.io/jobs', 'job_canceled', dict(unified_job_id=task.id))
|
emit_websocket_notification('/socket.io/jobs', 'status_changed', dict(unified_job_id=task.id))
|
||||||
running_tasks.pop(running_tasks.index(task))
|
running_tasks.pop(running_tasks.index(task))
|
||||||
print("Task %s appears orphaned... marking as failed" % task)
|
print("Task %s appears orphaned... marking as failed" % task)
|
||||||
|
|
||||||
|
|||||||
@@ -583,7 +583,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
|||||||
if not all(opts.values()):
|
if not all(opts.values()):
|
||||||
return False
|
return False
|
||||||
self.update_fields(start_args=json.dumps(kwargs), status='pending')
|
self.update_fields(start_args=json.dumps(kwargs), status='pending')
|
||||||
emit_websocket_notification('/socket.io/jobs', 'job_started', dict(unified_job_id=self.id))
|
emit_websocket_notification('/socket.io/jobs', 'status_changed', dict(unified_job_id=self.id))
|
||||||
task_type = get_type_for_model(self)
|
task_type = get_type_for_model(self)
|
||||||
# notify_task_runner.delay(dict(task_type=task_type, id=self.id, metadata=kwargs))
|
# notify_task_runner.delay(dict(task_type=task_type, id=self.id, metadata=kwargs))
|
||||||
return True
|
return True
|
||||||
@@ -623,6 +623,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
|||||||
instance.job_explanation = 'Forced cancel'
|
instance.job_explanation = 'Forced cancel'
|
||||||
update_fields.append('job_explanation')
|
update_fields.append('job_explanation')
|
||||||
instance.save(update_fields=update_fields)
|
instance.save(update_fields=update_fields)
|
||||||
|
emit_websocket_notification('/socket.io/jobs', 'status_changed', dict(unified_job_id=instance.id))
|
||||||
except: # FIXME: Log this exception!
|
except: # FIXME: Log this exception!
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
raise
|
raise
|
||||||
@@ -632,7 +633,7 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
|||||||
if not self.cancel_flag:
|
if not self.cancel_flag:
|
||||||
self.cancel_flag = True
|
self.cancel_flag = True
|
||||||
self.save(update_fields=['cancel_flag'])
|
self.save(update_fields=['cancel_flag'])
|
||||||
emit_websocket_notification('/socket.io/jobs', 'job_canceled', dict(unified_job_id=self.id))
|
emit_websocket_notification('/socket.io/jobs', 'status_changed', dict(unified_job_id=self.id))
|
||||||
if settings.BROKER_URL.startswith('amqp://'):
|
if settings.BROKER_URL.startswith('amqp://'):
|
||||||
self._force_cancel()
|
self._force_cancel()
|
||||||
return self.cancel_flag
|
return self.cancel_flag
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ def tower_periodic_scheduler(self):
|
|||||||
new_unified_job.status = 'failed'
|
new_unified_job.status = 'failed'
|
||||||
new_unified_job.job_explanation = "Scheduled job could not start because it was not in the right state or required manual credentials"
|
new_unified_job.job_explanation = "Scheduled job could not start because it was not in the right state or required manual credentials"
|
||||||
new_unified_job.save(update_fields=['job_status', 'job_explanation'])
|
new_unified_job.save(update_fields=['job_status', 'job_explanation'])
|
||||||
|
emit_websocket_notification('/socket.io/jobs', 'status_changed', dict(unified_job_id=new_unified_job.id))
|
||||||
|
|
||||||
@task()
|
@task()
|
||||||
def notify_task_runner(metadata_dict):
|
def notify_task_runner(metadata_dict):
|
||||||
@@ -123,7 +124,7 @@ def handle_work_error(self, task_id, subtasks=None):
|
|||||||
instance.job_explanation = "Previous Task Failed: %s for %s with celery task id: %s" % \
|
instance.job_explanation = "Previous Task Failed: %s for %s with celery task id: %s" % \
|
||||||
(first_task_type, first_task_name, task_id)
|
(first_task_type, first_task_name, task_id)
|
||||||
instance.save()
|
instance.save()
|
||||||
emit_websocket_notification('/socket.io/jobs', 'job_error', dict(unified_job_id=instance.id))
|
emit_websocket_notification('/socket.io/jobs', 'status_changed', dict(unified_job_id=instance.id))
|
||||||
|
|
||||||
class BaseTask(Task):
|
class BaseTask(Task):
|
||||||
|
|
||||||
@@ -334,7 +335,7 @@ class BaseTask(Task):
|
|||||||
'''
|
'''
|
||||||
Run the job/task and capture its output.
|
Run the job/task and capture its output.
|
||||||
'''
|
'''
|
||||||
emit_websocket_notification('/socket.io/jobs', 'job_running', dict(unified_job_id=pk))
|
emit_websocket_notification('/socket.io/jobs', 'status_changed', dict(unified_job_id=pk))
|
||||||
instance = self.update_model(pk, status='running', celery_task_id=self.request.id)
|
instance = self.update_model(pk, status='running', celery_task_id=self.request.id)
|
||||||
status, tb = 'error', ''
|
status, tb = 'error', ''
|
||||||
output_replacements = []
|
output_replacements = []
|
||||||
@@ -383,7 +384,7 @@ class BaseTask(Task):
|
|||||||
instance = self.update_model(pk, status=status, result_traceback=tb,
|
instance = self.update_model(pk, status=status, result_traceback=tb,
|
||||||
output_replacements=output_replacements)
|
output_replacements=output_replacements)
|
||||||
self.post_run_hook(instance, **kwargs)
|
self.post_run_hook(instance, **kwargs)
|
||||||
emit_websocket_notification('/socket.io/jobs', 'job_finished', dict(unified_job_id=pk))
|
emit_websocket_notification('/socket.io/jobs', 'status_changed', dict(unified_job_id=pk))
|
||||||
if status != 'successful' and not hasattr(settings, 'CELERY_UNIT_TEST'):
|
if status != 'successful' and not hasattr(settings, 'CELERY_UNIT_TEST'):
|
||||||
# Raising an exception will mark the job as 'failed' in celery
|
# Raising an exception will mark the job as 'failed' in celery
|
||||||
# and will stop a task chain from continuing to execute
|
# and will stop a task chain from continuing to execute
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ from Crypto.Cipher import AES
|
|||||||
# ZeroMQ
|
# ZeroMQ
|
||||||
import zmq
|
import zmq
|
||||||
|
|
||||||
|
# Django
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
__all__ = ['get_object_or_400', 'get_object_or_403', 'camelcase_to_underscore',
|
__all__ = ['get_object_or_400', 'get_object_or_403', 'camelcase_to_underscore',
|
||||||
'get_ansible_version', 'get_awx_version', 'update_scm_url',
|
'get_ansible_version', 'get_awx_version', 'update_scm_url',
|
||||||
'get_type_for_model', 'get_model_for_type']
|
'get_type_for_model', 'get_model_for_type']
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ function SocketsController ($scope, $compile, ClearScope, Socket) {
|
|||||||
e = angular.element(document.getElementById('job-events-container'));
|
e = angular.element(document.getElementById('job-events-container'));
|
||||||
e.append(html);
|
e.append(html);
|
||||||
$compile(e)(job_events_scope);
|
$compile(e)(job_events_scope);
|
||||||
|
|
||||||
test_socket.init();
|
test_socket.init();
|
||||||
jobs_socket.init();
|
jobs_socket.init();
|
||||||
job_events_socket.init();
|
job_events_socket.init();
|
||||||
@@ -51,6 +51,10 @@ function SocketsController ($scope, $compile, ClearScope, Socket) {
|
|||||||
test_socket.on('test', function(data) {
|
test_socket.on('test', function(data) {
|
||||||
test_scope.messages.push(data);
|
test_scope.messages.push(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jobs_socket.on("status_changed", function(data) {
|
||||||
|
jobs_scope.messages.push(data);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketsController.$inject = [ '$scope', '$compile', 'ClearScope', 'Socket'];
|
SocketsController.$inject = [ '$scope', '$compile', 'ClearScope', 'Socket'];
|
||||||
|
|||||||
Reference in New Issue
Block a user