Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(projectTransferOwnership): update comments and rename tasks for clarity #5511

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions kobo/apps/project_ownership/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def garbage_collector():
@celery_app.task
def mark_as_expired():
"""
Flag as expired not accepted (or declined) invites after
Mark as expired any invites that were not accepted or declined after X days
(X is configurable in Constance)
"""
# Avoid circular import
Invite = apps.get_model('project_ownership', 'Invite') # noqa
Expand Down Expand Up @@ -191,10 +192,12 @@ def mark_as_expired():


@celery_app.task
def mark_stuck_tasks_as_failed():
def mark_as_failed():
"""
Flag tasks as failed if they have been created for a long time.
Mark tasks as failed if they have been pending for too long.
The threshold period is configurable in Constance (`PROJECT_OWNERSHIP_STUCK_THRESHOLD`). # noqa
"""

# Avoid circular import
TransferStatus = apps.get_model('project_ownership', 'TransferStatus') # noqa
stuck_threshold = timezone.now() - timedelta(
Expand Down Expand Up @@ -242,7 +245,7 @@ def send_email_to_admins(invite_uid: str):


@celery_app.task
def task_rescheduler():
def task_restarter():
"""
This task restarts previous tasks which have been stopped accidentally,
e.g.: docker container/k8s pod restart or OOM killed.
Expand All @@ -262,7 +265,7 @@ def task_rescheduler():
minutes=config.PROJECT_OWNERSHIP_STUCK_THRESHOLD
)

# Resume stopped involuntarily tasks
# Restart tasks that were stopped unintentionally.
for transfer_status in TransferStatus.objects.filter(
date_modified__lte=resume_threshold,
date_created__gt=stuck_threshold,
Expand Down
8 changes: 4 additions & 4 deletions kobo/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,14 +1205,14 @@ def dj_stripe_request_callback_method():
'options': {'queue': 'kobocat_queue'}
},
# Schedule every 10 minutes
'project-ownership-task-scheduler': {
'task': 'kobo.apps.project_ownership.tasks.task_rescheduler',
'project-ownership-task-restarter': {
'task': 'kobo.apps.project_ownership.tasks.task_restarter',
'schedule': crontab(minute='*/10'),
'options': {'queue': 'kpi_low_priority_queue'}
},
# Schedule every 30 minutes
'project-ownership-mark-stuck-tasks-as-failed': {
'task': 'kobo.apps.project_ownership.tasks.mark_stuck_tasks_as_failed',
'project-ownership-mark-as-failed': {
'task': 'kobo.apps.project_ownership.tasks.mark_as_failed',
'schedule': crontab(minute='*/30'),
'options': {'queue': 'kpi_low_priority_queue'}
},
Expand Down
Loading