mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 01:08:48 -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:
@@ -40,26 +40,9 @@ def create_system_job_templates(apps, schema_editor):
|
|||||||
modified=now_dt,
|
modified=now_dt,
|
||||||
)
|
)
|
||||||
|
|
||||||
sjt, created = SystemJobTemplate.objects.get_or_create(
|
existing_cd_jobs = SystemJobTemplate.objects.filter(job_type='cleanup_deleted')
|
||||||
job_type='cleanup_deleted',
|
Schedule.objects.filter(unified_job_template__in=existing_cd_jobs).delete()
|
||||||
defaults=dict(
|
existing_cd_jobs.delete()
|
||||||
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,
|
|
||||||
)
|
|
||||||
|
|
||||||
sjt, created = SystemJobTemplate.objects.get_or_create(
|
sjt, created = SystemJobTemplate.objects.get_or_create(
|
||||||
job_type='cleanup_activitystream',
|
job_type='cleanup_activitystream',
|
||||||
|
|||||||
@@ -117,6 +117,10 @@ def run_label_cleanup(self):
|
|||||||
qs.delete()
|
qs.delete()
|
||||||
return labels_count
|
return labels_count
|
||||||
|
|
||||||
|
@task(bind=True)
|
||||||
|
def cleanup_authtokens(self):
|
||||||
|
AuthToken.objects.filter(expires__lt=now()).delete()
|
||||||
|
|
||||||
@task(bind=True)
|
@task(bind=True)
|
||||||
def tower_periodic_scheduler(self):
|
def tower_periodic_scheduler(self):
|
||||||
def get_last_run():
|
def get_last_run():
|
||||||
@@ -1689,13 +1693,6 @@ class RunSystemJob(BaseTask):
|
|||||||
args.extend(['--older_than', str(json_vars['older_than'])])
|
args.extend(['--older_than', str(json_vars['older_than'])])
|
||||||
if 'granularity' in json_vars:
|
if 'granularity' in json_vars:
|
||||||
args.extend(['--granularity', str(json_vars['granularity'])])
|
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:
|
except Exception, e:
|
||||||
logger.error("Failed to parse system job: " + str(e))
|
logger.error("Failed to parse system job: " + str(e))
|
||||||
return args
|
return args
|
||||||
|
|||||||
@@ -349,6 +349,10 @@ CELERYBEAT_SCHEDULE = {
|
|||||||
'task': 'awx.main.tasks.run_label_cleanup',
|
'task': 'awx.main.tasks.run_label_cleanup',
|
||||||
'schedule': timedelta(days=7)
|
'schedule': timedelta(days=7)
|
||||||
},
|
},
|
||||||
|
'authtoken_cleanup': {
|
||||||
|
'task': 'awx.main.tasks.cleanup_authtokens',
|
||||||
|
'schedule': timedelta(days=30)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
# Social Auth configuration.
|
# Social Auth configuration.
|
||||||
|
|||||||
Reference in New Issue
Block a user