Repository: ansible/awx

Issue:
AWX ships analytics bundle multiple times per upload window. 
##### ISSUE TYPE
 - Bug Report

##### SUMMARY
AWX ships analytics bundle multiple times per upload window. 

##### ENVIRONMENT
* AWX version: X.Y.Z
* AWX install method: openshift, minishift, docker on linux, docker for mac, boot2docker
* Ansible version:  2.10.0.dev0 
* Operating System: Red Hat Enterprise Linux Server release 7.7 (Maipo) 
* Web Browser: N/A

##### STEPS TO REPRODUCE

Create a clustered environment.   Enable debug logging.  Wait for an upload window (*/6 hour)

> tail -n 10000 -f tower.log | grep 'shipping analytics file'

##### EXPECTED RESULTS

A single bundle upload.

-bash-4.2$ tail -n 10000 -f tower.log | grep 'shipping analytics file'
2020-01-20 18:00:00,875 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-180000+0000.tar.gz

##### ACTUAL RESULTS

Multiple bundles are uploaded with the same data.    It seems to be uploading every minute for an hour ever 4 hours.   It is sending 60 times more uploads than required. 

> -bash-4.2$ tail -n 10000 -f tower.log | grep 'shipping analytics file'
> 2020-01-20 18:00:00,875 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-180000+0000.tar.gz
> 2020-01-20 18:01:00,568 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-180100+0000.tar.gz
> 2020-01-20 18:02:00,673 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-180200+0000.tar.gz
> 2020-01-20 18:03:00,575 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-180300+0000.tar.gz
> 2020-01-20 18:04:00,689 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-180400+0000.tar.gz
> 2020-01-20 18:05:00,549 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-180500+0000.tar.gz
> 2020-01-20 18:06:00,681 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-180600+0000.tar.gz
> 2020-01-20 18:07:00,567 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-180700+0000.tar.gz
> 2020-01-20 18:08:00,587 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-180800+0000.tar.gz
> 2020-01-20 18:09:00,683 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-180900+0000.tar.gz
> 2020-01-20 18:10:00,614 DEBUG    awx.main.analytics shipping analytics file: /tmp/2afc1cba-4f00-4346-bb8b-a0a70c65aec1_2020-01-20-181000+0000.tar.gz


##### ADDITIONAL INFORMATION




Discussion:

Resolving patch:
diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py
--- a/awx/settings/defaults.py
+++ b/awx/settings/defaults.py
@@ -6,6 +6,7 @@
 import sys
 from datetime import timedelta
 from celery.schedules import crontab
+import random
 
 # global settings
 from django.conf import global_settings
@@ -441,7 +442,7 @@ def IS_TESTING(argv=None):
     },
     'gather_analytics': {
         'task': 'awx.main.tasks.gather_analytics',
-        'schedule': crontab(hour='*/6')
+        'schedule': crontab(hour='*/6', minute=random.randint(0,59))
     },
     'task_manager': {
         'task': 'awx.main.scheduler.tasks.run_task_manager',


Test patch: