mirror of
https://github.com/ansible/awx.git
synced 2026-04-05 01:59:25 -02:30
Add some conditions for always-send and never-send event types
Always send websocket messages for high priority events like playbook_on_stats Never send websocket messages for events with no output unless they are a high priority event type
This commit is contained in:
@@ -41,6 +41,7 @@ STANDARD_INVENTORY_UPDATE_ENV = {
|
|||||||
}
|
}
|
||||||
CAN_CANCEL = ('new', 'pending', 'waiting', 'running')
|
CAN_CANCEL = ('new', 'pending', 'waiting', 'running')
|
||||||
ACTIVE_STATES = CAN_CANCEL
|
ACTIVE_STATES = CAN_CANCEL
|
||||||
|
MINIMAL_EVENTS = set(['playbook_on_play_start', 'playbook_on_task_start', 'playbook_on_stats', 'EOF'])
|
||||||
CENSOR_VALUE = '************'
|
CENSOR_VALUE = '************'
|
||||||
ENV_BLOCKLIST = frozenset(
|
ENV_BLOCKLIST = frozenset(
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from awx.api.versioning import reverse
|
|||||||
from awx.main import consumers
|
from awx.main import consumers
|
||||||
from awx.main.managers import DeferJobCreatedManager
|
from awx.main.managers import DeferJobCreatedManager
|
||||||
from awx.main.fields import JSONField
|
from awx.main.fields import JSONField
|
||||||
|
from awx.main.constants import MINIMAL_EVENTS
|
||||||
from awx.main.models.base import CreatedModifiedModel
|
from awx.main.models.base import CreatedModifiedModel
|
||||||
from awx.main.utils import ignore_inventory_computed_fields, camelcase_to_underscore
|
from awx.main.utils import ignore_inventory_computed_fields, camelcase_to_underscore
|
||||||
|
|
||||||
@@ -57,9 +58,6 @@ def create_host_status_counts(event_data):
|
|||||||
return dict(host_status_counts)
|
return dict(host_status_counts)
|
||||||
|
|
||||||
|
|
||||||
MINIMAL_EVENTS = set(['playbook_on_play_start', 'playbook_on_task_start', 'playbook_on_stats', 'EOF'])
|
|
||||||
|
|
||||||
|
|
||||||
def emit_event_detail(event):
|
def emit_event_detail(event):
|
||||||
if settings.UI_LIVE_UPDATES_ENABLED is False and event.event not in MINIMAL_EVENTS:
|
if settings.UI_LIVE_UPDATES_ENABLED is False and event.event not in MINIMAL_EVENTS:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ from receptorctl.socket_interface import ReceptorControl
|
|||||||
|
|
||||||
# AWX
|
# AWX
|
||||||
from awx import __version__ as awx_application_version
|
from awx import __version__ as awx_application_version
|
||||||
from awx.main.constants import PRIVILEGE_ESCALATION_METHODS, STANDARD_INVENTORY_UPDATE_ENV
|
from awx.main.constants import PRIVILEGE_ESCALATION_METHODS, STANDARD_INVENTORY_UPDATE_ENV, MINIMAL_EVENTS
|
||||||
from awx.main.access import access_registry
|
from awx.main.access import access_registry
|
||||||
from awx.main.redact import UriCleaner
|
from awx.main.redact import UriCleaner
|
||||||
from awx.main.models import (
|
from awx.main.models import (
|
||||||
@@ -1158,17 +1158,25 @@ class BaseTask(object):
|
|||||||
first_window_time = self.recent_event_timings[0]
|
first_window_time = self.recent_event_timings[0]
|
||||||
last_window_time = self.recent_event_timings[-1]
|
last_window_time = self.recent_event_timings[-1]
|
||||||
|
|
||||||
should_emit = bool(
|
if event_data.get('event') in MINIMAL_EVENTS:
|
||||||
# if 30the most recent websocket message was sent over 1 second ago
|
should_emit = True # always send some types like playbook_on_stats
|
||||||
cpu_time - first_window_time > 1.0
|
if event_data.get('stdout') == '' and event_data['start_line'] == event_data['end_line']:
|
||||||
# if the very last websocket message came in over 1/30 seconds ago
|
should_emit = False # exclude events with no output
|
||||||
or self.recent_event_timings.maxlen * (cpu_time - last_window_time) > 1.0
|
else:
|
||||||
# if the queue is not yet full
|
should_emit = any(
|
||||||
or (len(self.recent_event_timings) != self.recent_event_timings.maxlen)
|
[
|
||||||
)
|
# if 30the most recent websocket message was sent over 1 second ago
|
||||||
|
cpu_time - first_window_time > 1.0,
|
||||||
|
# if the very last websocket message came in over 1/30 seconds ago
|
||||||
|
self.recent_event_timings.maxlen * (cpu_time - last_window_time) > 1.0,
|
||||||
|
# if the queue is not yet full
|
||||||
|
len(self.recent_event_timings) != self.recent_event_timings.maxlen,
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'Event {} websocket send {}, queue {}, avg rate {}, last rate {}'.format(
|
'Job {} event {} websocket send {}, queued: {}, rate - avg: {:.3f}, last: {:.3f}'.format(
|
||||||
|
self.instance.id,
|
||||||
event_data.get('counter', 0),
|
event_data.get('counter', 0),
|
||||||
should_emit,
|
should_emit,
|
||||||
len(self.recent_event_timings),
|
len(self.recent_event_timings),
|
||||||
|
|||||||
Reference in New Issue
Block a user