mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 14:27:42 -02:30
Merge pull request #8193 from ryanpetrello/ws-broadcast-limited
add a few additional optimizations to the callback receiver Reviewed-by: Shane McDonald <me@shanemcd.com> https://github.com/shanemcd
This commit is contained in:
@@ -17,6 +17,8 @@ from django.utils.functional import cached_property
|
|||||||
# Django REST Framework
|
# Django REST Framework
|
||||||
from rest_framework.fields import empty, SkipField
|
from rest_framework.fields import empty, SkipField
|
||||||
|
|
||||||
|
import cachetools
|
||||||
|
|
||||||
# Tower
|
# Tower
|
||||||
from awx.main.utils import encrypt_field, decrypt_field
|
from awx.main.utils import encrypt_field, decrypt_field
|
||||||
from awx.conf import settings_registry
|
from awx.conf import settings_registry
|
||||||
@@ -28,6 +30,8 @@ from awx.conf.migrations._reencrypt import decrypt_field as old_decrypt_field
|
|||||||
|
|
||||||
logger = logging.getLogger('awx.conf.settings')
|
logger = logging.getLogger('awx.conf.settings')
|
||||||
|
|
||||||
|
SETTING_MEMORY_TTL = 5 if 'callback_receiver' in ' '.join(sys.argv) else 0
|
||||||
|
|
||||||
# Store a special value to indicate when a setting is not set in the database.
|
# Store a special value to indicate when a setting is not set in the database.
|
||||||
SETTING_CACHE_NOTSET = '___notset___'
|
SETTING_CACHE_NOTSET = '___notset___'
|
||||||
|
|
||||||
@@ -406,6 +410,7 @@ class SettingsWrapper(UserSettingsHolder):
|
|||||||
def SETTINGS_MODULE(self):
|
def SETTINGS_MODULE(self):
|
||||||
return self._get_default('SETTINGS_MODULE')
|
return self._get_default('SETTINGS_MODULE')
|
||||||
|
|
||||||
|
@cachetools.cached(cache=cachetools.TTLCache(maxsize=2048, ttl=SETTING_MEMORY_TTL))
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
value = empty
|
value = empty
|
||||||
if name in self.all_supported_settings:
|
if name in self.all_supported_settings:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import datetime
|
|||||||
import logging
|
import logging
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.db import models, DatabaseError, connection
|
from django.db import models, DatabaseError, connection
|
||||||
from django.utils.dateparse import parse_datetime
|
from django.utils.dateparse import parse_datetime
|
||||||
from django.utils.text import Truncator
|
from django.utils.text import Truncator
|
||||||
@@ -57,7 +58,18 @@ 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
|
||||||
|
):
|
||||||
|
return
|
||||||
cls = event.__class__
|
cls = event.__class__
|
||||||
relation = {
|
relation = {
|
||||||
JobEvent: 'job_id',
|
JobEvent: 'job_id',
|
||||||
@@ -368,10 +380,11 @@ class BasePlaybookEvent(CreatedModifiedModel):
|
|||||||
value = force_text(event_data.get(field, '')).strip()
|
value = force_text(event_data.get(field, '')).strip()
|
||||||
if value != getattr(self, field):
|
if value != getattr(self, field):
|
||||||
setattr(self, field, value)
|
setattr(self, field, value)
|
||||||
analytics_logger.info(
|
if settings.LOG_AGGREGATOR_ENABLED:
|
||||||
'Event data saved.',
|
analytics_logger.info(
|
||||||
extra=dict(python_objects=dict(job_event=self))
|
'Event data saved.',
|
||||||
)
|
extra=dict(python_objects=dict(job_event=self))
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_from_data(cls, **kwargs):
|
def create_from_data(cls, **kwargs):
|
||||||
|
|||||||
@@ -119,6 +119,10 @@ function OutputStream ($q) {
|
|||||||
this.counters.ready = ready;
|
this.counters.ready = ready;
|
||||||
this.counters.used = used;
|
this.counters.used = used;
|
||||||
this.counters.missing = missing;
|
this.counters.missing = missing;
|
||||||
|
|
||||||
|
if (!window.liveUpdates) {
|
||||||
|
this.counters.ready = event.counter;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.bufferEmpty = threshold => {
|
this.bufferEmpty = threshold => {
|
||||||
@@ -141,6 +145,10 @@ function OutputStream ($q) {
|
|||||||
const { total } = this.counters;
|
const { total } = this.counters;
|
||||||
const readyCount = this.getReadyCount();
|
const readyCount = this.getReadyCount();
|
||||||
|
|
||||||
|
if (!window.liveUpdates) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (readyCount <= 0) {
|
if (readyCount <= 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,13 @@ describe('Output | StreamService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('isReadyToRender', () => {
|
describe('isReadyToRender', () => {
|
||||||
it("it's never ready to render unless the result of getReadyCount is greater than 0", () => {
|
it("it's never ready to render when live updates are enabled unless the result of getReadyCount is greater than 0", () => {
|
||||||
|
delete window.liveUpdates;
|
||||||
|
Object.defineProperty(window, 'liveUpdates', {
|
||||||
|
value: true,
|
||||||
|
writable: false
|
||||||
|
});
|
||||||
|
|
||||||
const params = [
|
const params = [
|
||||||
[-1, false],
|
[-1, false],
|
||||||
[0, false],
|
[0, false],
|
||||||
|
|||||||
Reference in New Issue
Block a user