mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 10:27:37 -02:30
Merge pull request #3092 from chrismeyersfsu/remove-label_cleanup_job
forgot to remove label cleanup periodic task
This commit is contained in:
@@ -47,7 +47,6 @@ from django.contrib.auth.models import User
|
|||||||
from awx.main.constants import CLOUD_PROVIDERS
|
from awx.main.constants import CLOUD_PROVIDERS
|
||||||
from awx.main.models import * # noqa
|
from awx.main.models import * # noqa
|
||||||
from awx.main.models import UnifiedJob
|
from awx.main.models import UnifiedJob
|
||||||
from awx.main.models.label import Label
|
|
||||||
from awx.main.queue import FifoQueue
|
from awx.main.queue import FifoQueue
|
||||||
from awx.main.conf import tower_settings
|
from awx.main.conf import tower_settings
|
||||||
from awx.main.task_engine import TaskSerializer, TASK_TIMEOUT_INTERVAL
|
from awx.main.task_engine import TaskSerializer, TASK_TIMEOUT_INTERVAL
|
||||||
@@ -123,13 +122,6 @@ def run_administrative_checks(self):
|
|||||||
tower_admin_emails,
|
tower_admin_emails,
|
||||||
fail_silently=True)
|
fail_silently=True)
|
||||||
|
|
||||||
@task(bind=True)
|
|
||||||
def run_label_cleanup(self):
|
|
||||||
qs = Label.get_orphaned_labels()
|
|
||||||
labels_count = qs.count()
|
|
||||||
qs.delete()
|
|
||||||
return labels_count
|
|
||||||
|
|
||||||
@task(bind=True)
|
@task(bind=True)
|
||||||
def cleanup_authtokens(self):
|
def cleanup_authtokens(self):
|
||||||
AuthToken.objects.filter(expires__lt=now()).delete()
|
AuthToken.objects.filter(expires__lt=now()).delete()
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ from django.conf import settings
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
@pytest.mark.parametrize("job_name,function_path", [
|
@pytest.mark.parametrize("job_name,function_path", [
|
||||||
('label_cleanup', 'awx.main.tasks.run_label_cleanup'),
|
|
||||||
('admin_checks', 'awx.main.tasks.run_administrative_checks'),
|
('admin_checks', 'awx.main.tasks.run_administrative_checks'),
|
||||||
('tower_scheduler', 'awx.main.tasks.tower_periodic_scheduler'),
|
('tower_scheduler', 'awx.main.tasks.tower_periodic_scheduler'),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ from awx.main.models import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from awx.main.tasks import (
|
from awx.main.tasks import (
|
||||||
run_label_cleanup,
|
|
||||||
send_notifications,
|
send_notifications,
|
||||||
run_administrative_checks,
|
run_administrative_checks,
|
||||||
)
|
)
|
||||||
@@ -21,16 +20,6 @@ def apply_patches(_patches):
|
|||||||
yield
|
yield
|
||||||
[p.stop() for p in _patches]
|
[p.stop() for p in _patches]
|
||||||
|
|
||||||
def test_run_label_cleanup(mocker):
|
|
||||||
qs = mocker.Mock(**{'count.return_value': 3, 'delete.return_value': None})
|
|
||||||
mock_label = mocker.patch('awx.main.models.label.Label.get_orphaned_labels',return_value=qs)
|
|
||||||
|
|
||||||
ret = run_label_cleanup()
|
|
||||||
|
|
||||||
mock_label.assert_called_with()
|
|
||||||
qs.delete.assert_called_with()
|
|
||||||
assert 3 == ret
|
|
||||||
|
|
||||||
def test_send_notifications_not_list():
|
def test_send_notifications_not_list():
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
send_notifications(None)
|
send_notifications(None)
|
||||||
|
|||||||
@@ -345,10 +345,6 @@ CELERYBEAT_SCHEDULE = {
|
|||||||
'task': 'awx.main.tasks.run_administrative_checks',
|
'task': 'awx.main.tasks.run_administrative_checks',
|
||||||
'schedule': timedelta(days=30)
|
'schedule': timedelta(days=30)
|
||||||
},
|
},
|
||||||
'label_cleanup': {
|
|
||||||
'task': 'awx.main.tasks.run_label_cleanup',
|
|
||||||
'schedule': timedelta(days=7)
|
|
||||||
},
|
|
||||||
'authtoken_cleanup': {
|
'authtoken_cleanup': {
|
||||||
'task': 'awx.main.tasks.cleanup_authtokens',
|
'task': 'awx.main.tasks.cleanup_authtokens',
|
||||||
'schedule': timedelta(days=30)
|
'schedule': timedelta(days=30)
|
||||||
|
|||||||
Reference in New Issue
Block a user