Skip to content

Add admin action to delete scheduled maintenance tasks - #464

Merged
gaidheal1 merged 7 commits into
developmentfrom
gaidheal1-issue-140-delete-scheduled-maintenance-t
Jun 28, 2026
Merged

Add admin action to delete scheduled maintenance tasks#464
gaidheal1 merged 7 commits into
developmentfrom
gaidheal1-issue-140-delete-scheduled-maintenance-t

Conversation

@gaidheal1

Copy link
Copy Markdown
Member

Admins currently have no way to cancel the Celery tasks (warnings + activation) that get queued when a maintenance window is scheduled. This means if a window is changed or cancelled, stale tasks will still fire at the original times.

Approach

To make revocation possible, task IDs need to be persisted at scheduling time. The changes:

  • MaintenanceWindow model -- adds a scheduled_task_ids JSONField to store the Celery task IDs returned by apply_async when schedule_tasks() is called.
  • delete_scheduled_tasks() method -- new model method that calls current_app.control.revoke() on each stored task ID, then resets tasks_scheduled = False and clears the list.
  • Django admin -- adds a delete_tasks view handler and /delete-tasks/ URL following the same pattern as the existing schedule_tasks handler, plus a "Delete scheduled tasks" button in the change-form template.
  • Migration -- adds scheduled_task_ids to the MaintenanceWindow table.

Revocation without terminate=True is used since warning and activation tasks are queued for future execution and won't have started yet.

Fixes: #140

gaidheal1 and others added 7 commits June 23, 2026 19:41
Add guidelines for bug reports, feature requests, and code contributions.
Create CONTRIBUTING.md with contribution guidelines
Timer stop & auth session hotfix
Multiple concurrent 401 responses each called clearAuthAndRedirect(),
scheduling separate window.location.href redirects that fired in sequence
and repeatedly reloaded /login.

Replace the hard redirect with a custom DOM event (auth:expired).
AuthContext listens for it and calls logout(), setting isAuthenticated=false.
PrivateRoute then does a single React Router navigate to /login — no hard
reload, no loop.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix(auth): prevent repeated login-page reloads on session expiry
- Add scheduled_task_ids JSONField to MaintenanceWindow to track Celery task IDs
- Update schedule_tasks() to capture and store task IDs from apply_async
- Implement delete_scheduled_tasks() to revoke tasks via Celery control API
- Add delete_tasks admin view handler and URL (/delete-tasks/)
- Pass delete_url in change_view context
- Add 'Delete scheduled tasks' button to admin change form template
- Add migration for scheduled_task_ids field

Closes #140

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gaidheal1
gaidheal1 changed the base branch from main to development June 28, 2026 14:15
@gaidheal1
gaidheal1 merged commit 7776022 into development Jun 28, 2026
6 checks passed
@gaidheal1
gaidheal1 deleted the gaidheal1-issue-140-delete-scheduled-maintenance-t branch July 1, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maintenance windows: add admin action to delete scheduled tasks

1 participant