From d0e160a037dec3565e1e4b04ea5beb4c937d7bb1 Mon Sep 17 00:00:00 2001 From: Christian Adams Date: Tue, 14 May 2019 17:14:44 -0400 Subject: [PATCH] collect events based on last ship, not collection --- awx/main/analytics/core.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/awx/main/analytics/core.py b/awx/main/analytics/core.py index 4e97261c90..fd5295b4d1 100644 --- a/awx/main/analytics/core.py +++ b/awx/main/analytics/core.py @@ -61,13 +61,11 @@ def gather(dest=None, module=None): :pararm module: the module to search for registered analytic collector functions; defaults to awx.main.analytics.collectors """ - + run_now = now() state = TowerAnalyticsState.get_solo() last_run = state.last_run logger.debug("Last analytics run was: {}".format(last_run)) - state.last_run = run_now - state.save() max_interval = now() - timedelta(days=7) if last_run < max_interval or not last_run: @@ -132,6 +130,12 @@ def ship(path): ] output = smart_str(subprocess.check_output(cmd, timeout=60 * 5)) logger.debug(output) + # reset the `last_run` when data is shipped + run_now = now() + state = TowerAnalyticsState.get_solo() + state.last_run = run_now + state.save() + except subprocess.CalledProcessError: logger.exception('{} failure:'.format(cmd)) except subprocess.TimeoutExpired: