mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 19:10:07 -03:30
Purge cleanup_deleted tasks as they aren't needed
This also adds a periodic static task to cleanup auth tokens
This commit is contained in:
parent
3c90ecba0b
commit
6cece17024
@ -40,26 +40,9 @@ def create_system_job_templates(apps, schema_editor):
|
||||
modified=now_dt,
|
||||
)
|
||||
|
||||
sjt, created = SystemJobTemplate.objects.get_or_create(
|
||||
job_type='cleanup_deleted',
|
||||
defaults=dict(
|
||||
name='Cleanup Deleted Data',
|
||||
description='Remove deleted object history older than X days',
|
||||
created=now_dt,
|
||||
modified=now_dt,
|
||||
polymorphic_ctype=sjt_ct,
|
||||
),
|
||||
)
|
||||
if created:
|
||||
sjt.schedules.create(
|
||||
name='Cleanup Deleted Data Schedule',
|
||||
rrule='DTSTART:%s RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=MO' % now_str,
|
||||
description='Automatically Generated Schedule',
|
||||
enabled=True,
|
||||
extra_data={'days': '30'},
|
||||
created=now_dt,
|
||||
modified=now_dt,
|
||||
)
|
||||
existing_cd_jobs = SystemJobTemplate.objects.filter(job_type='cleanup_deleted')
|
||||
Schedule.objects.filter(unified_job_template__in=existing_cd_jobs).delete()
|
||||
existing_cd_jobs.delete()
|
||||
|
||||
sjt, created = SystemJobTemplate.objects.get_or_create(
|
||||
job_type='cleanup_activitystream',
|
||||
|
||||
@ -117,6 +117,10 @@ def run_label_cleanup(self):
|
||||
qs.delete()
|
||||
return labels_count
|
||||
|
||||
@task(bind=True)
|
||||
def cleanup_authtokens(self):
|
||||
AuthToken.objects.filter(expires__lt=now()).delete()
|
||||
|
||||
@task(bind=True)
|
||||
def tower_periodic_scheduler(self):
|
||||
def get_last_run():
|
||||
@ -1689,13 +1693,6 @@ class RunSystemJob(BaseTask):
|
||||
args.extend(['--older_than', str(json_vars['older_than'])])
|
||||
if 'granularity' in json_vars:
|
||||
args.extend(['--granularity', str(json_vars['granularity'])])
|
||||
# Keeping this around in case we want to break this out
|
||||
# if 'jobs' in json_vars and json_vars['jobs']:
|
||||
# args.extend(['--jobs'])
|
||||
# if 'project_updates' in json_vars and json_vars['project_updates']:
|
||||
# args.extend(['--project-updates'])
|
||||
# if 'inventory_updates' in json_vars and json_vars['inventory_updates']:
|
||||
# args.extend(['--inventory-updates'])
|
||||
except Exception, e:
|
||||
logger.error("Failed to parse system job: " + str(e))
|
||||
return args
|
||||
|
||||
@ -349,6 +349,10 @@ CELERYBEAT_SCHEDULE = {
|
||||
'task': 'awx.main.tasks.run_label_cleanup',
|
||||
'schedule': timedelta(days=7)
|
||||
},
|
||||
'authtoken_cleanup': {
|
||||
'task': 'awx.main.tasks.cleanup_authtokens',
|
||||
'schedule': timedelta(days=30)
|
||||
},
|
||||
}
|
||||
|
||||
# Social Auth configuration.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user