-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: create stale submission cleanup task and other deployment twea…
…ks (#4358) * chore: disable beat container for dev * chore: use init option with celery container * chore: create cancel_stale_submissions task via migration * chore: revert accidental change included in last commit * chore: terminate celery docker-init.sh on failed command
- Loading branch information
1 parent
bd6d19e
commit 727feab
Showing
3 changed files
with
71 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/bin/bash -e | ||
# | ||
# Environment parameters: | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
ietf/submit/migrations/0010_create_cancel_stale_submissions_task.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Generated by Django 2.2.28 on 2022-08-23 08:45 | ||
|
||
from django.db import migrations | ||
from django.utils import timezone | ||
|
||
|
||
def forward(apps, schema_editor): | ||
IntervalSchedule = apps.get_model('django_celery_beat', 'IntervalSchedule') | ||
PeriodicTask = apps.get_model('django_celery_beat', 'PeriodicTask') | ||
PeriodicTasks = apps.get_model('django_celery_beat', 'PeriodicTasks') | ||
every_five_minutes, _ = IntervalSchedule.objects.get_or_create( | ||
every=5, | ||
period='minutes', # in non-migration code, use IntervalSchedule.MINUTES instead | ||
) | ||
task, _ = PeriodicTask.objects.get_or_create( | ||
interval=every_five_minutes, | ||
name='Cancel stale submissions', | ||
task='ietf.submit.tasks.cancel_stale_submissions', | ||
) | ||
# this replicates the PeriodicTasks.changed() call as of django-celery-beat==2.3.0 | ||
PeriodicTasks.objects.update_or_create(ident=1, defaults={'last_update': timezone.now()}) | ||
|
||
|
||
def reverse(apps, schema_editor): | ||
IntervalSchedule = apps.get_model('django_celery_beat', 'IntervalSchedule') | ||
PeriodicTask = apps.get_model('django_celery_beat', 'PeriodicTask') | ||
PeriodicTasks = apps.get_model('django_celery_beat', 'PeriodicTasks') | ||
every_five_minutes = IntervalSchedule.objects.get( | ||
every=5, | ||
period='minutes', # in non-migration code, use IntervalSchedule.MINUTES instead | ||
) | ||
task = PeriodicTask.objects.get( | ||
interval=every_five_minutes, | ||
name='Cancel stale submissions', | ||
task='ietf.submit.tasks.cancel_stale_submissions', | ||
) | ||
task.delete() | ||
every_five_minutes.delete() | ||
# this replicates the PeriodicTasks.changed() call as of django-celery-beat==2.3.0 | ||
PeriodicTasks.objects.update_or_create(ident=1, defaults={'last_update': timezone.now()}) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('submit', '0009_auto_20220427_1223'), | ||
('django_celery_beat', '0016_alter_crontabschedule_timezone'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(forward, reverse), | ||
] |