mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 09:27:36 -02:30
Require config collector data for all posts to analytics
We need the cluster ID when consuming all incoming data.
This commit is contained in:
@@ -134,6 +134,7 @@ def gather(dest=None, module=None, subset=None, since=None, until=None, collecti
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
from awx.conf.models import Setting
|
from awx.conf.models import Setting
|
||||||
|
from awx.main.analytics import collectors
|
||||||
from awx.main.signals import disable_activity_stream
|
from awx.main.signals import disable_activity_stream
|
||||||
|
|
||||||
if until is None:
|
if until is None:
|
||||||
@@ -143,22 +144,14 @@ def gather(dest=None, module=None, subset=None, since=None, until=None, collecti
|
|||||||
last_entries = last_entries.value if last_entries is not None else {}
|
last_entries = last_entries.value if last_entries is not None else {}
|
||||||
logger.debug("Last analytics run was: {}".format(settings.AUTOMATION_ANALYTICS_LAST_GATHER))
|
logger.debug("Last analytics run was: {}".format(settings.AUTOMATION_ANALYTICS_LAST_GATHER))
|
||||||
|
|
||||||
if module:
|
collector_module = module if module else collectors
|
||||||
collector_module = module
|
|
||||||
else:
|
|
||||||
from awx.main.analytics import collectors
|
|
||||||
|
|
||||||
collector_module = collectors
|
|
||||||
if subset: # ensure that the config collector is added to any explicit subset of our builtins
|
|
||||||
subset = set(subset) | {
|
|
||||||
'config',
|
|
||||||
}
|
|
||||||
|
|
||||||
collector_list = [
|
collector_list = [
|
||||||
func
|
func
|
||||||
for name, func in inspect.getmembers(collector_module)
|
for name, func in inspect.getmembers(collector_module)
|
||||||
if inspect.isfunction(func) and hasattr(func, '__awx_analytics_key__') and (not subset or name in subset)
|
if inspect.isfunction(func) and hasattr(func, '__awx_analytics_key__') and (not subset or name in subset)
|
||||||
]
|
]
|
||||||
|
if collection_type != 'dry-run' and not any(c.__awx_analytics_key__ == 'config' for c in collector_list):
|
||||||
|
collector_list.append(collectors.config)
|
||||||
json_collectors = [func for func in collector_list if func.__awx_analytics_type__ == 'json']
|
json_collectors = [func for func in collector_list if func.__awx_analytics_type__ == 'json']
|
||||||
csv_collectors = [func for func in collector_list if func.__awx_analytics_type__ == 'csv']
|
csv_collectors = [func for func in collector_list if func.__awx_analytics_type__ == 'csv']
|
||||||
|
|
||||||
@@ -182,6 +175,9 @@ def gather(dest=None, module=None, subset=None, since=None, until=None, collecti
|
|||||||
tarfiles.append(tgzfile)
|
tarfiles.append(tgzfile)
|
||||||
|
|
||||||
if collection_type != 'dry-run':
|
if collection_type != 'dry-run':
|
||||||
|
if data.get('config.json') is None:
|
||||||
|
logger.error("'config' collector data is missing, and is required to ship.")
|
||||||
|
return None
|
||||||
ship(tgzfile)
|
ship(tgzfile)
|
||||||
with disable_activity_stream():
|
with disable_activity_stream():
|
||||||
for filename in data:
|
for filename in data:
|
||||||
@@ -201,7 +197,13 @@ def gather(dest=None, module=None, subset=None, since=None, until=None, collecti
|
|||||||
if not files:
|
if not files:
|
||||||
continue
|
continue
|
||||||
for fpath in files:
|
for fpath in files:
|
||||||
tgzfile = package(dest.parent, {filename: (fpath, func.__awx_analytics_version__)}, until)
|
payload = {filename: (fpath, func.__awx_analytics_version__)}
|
||||||
|
if collection_type != 'dry-run':
|
||||||
|
payload['config.json'] = data.get('config.json')
|
||||||
|
if payload['config.json'] is None:
|
||||||
|
logger.error("'config' collector data is missing, and is required to ship.")
|
||||||
|
return None
|
||||||
|
tgzfile = package(dest.parent, payload, until)
|
||||||
if tgzfile is not None:
|
if tgzfile is not None:
|
||||||
tarfiles.append(tgzfile)
|
tarfiles.append(tgzfile)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user