diff --git a/application/api/user/tasks.py b/application/api/user/tasks.py index 05090e8e..7c4e2df7 100644 --- a/application/api/user/tasks.py +++ b/application/api/user/tasks.py @@ -140,6 +140,11 @@ def setup_periodic_tasks(sender, **kwargs): cleanup_pending_tool_state.s(), name="cleanup-pending-tool-state", ) + sender.add_periodic_task( + timedelta(hours=7), + version_check_task.s(), + name="version-check", + ) @celery.task(bind=True) @@ -176,3 +181,16 @@ def cleanup_pending_tool_state(self): with engine.begin() as conn: deleted = PendingToolStateRepository(conn).cleanup_expired() return {"deleted": deleted} + + +@celery.task(bind=True) +def version_check_task(self): + """Periodic anonymous version check. + + Complements the ``worker_ready`` boot trigger so long-running + deployments (>6h cache TTL) still refresh advisories. ``run_check`` + is fail-silent and coordinates across replicas via Redis lock + + cache (see ``application.updates.version_check``). + """ + from application.updates.version_check import run_check + run_check() diff --git a/application/updates/version_check.py b/application/updates/version_check.py index eeeaeab2..866793ba 100644 --- a/application/updates/version_check.py +++ b/application/updates/version_check.py @@ -1,9 +1,11 @@ -"""Anonymous startup version-check client. +"""Anonymous version-check client. -Called once per Celery worker boot (see ``application/celery_init.py`` -``worker_ready`` handler). Posts the running version + anonymous -instance UUID to ``gptcloud.arc53.com/api/check``, caches the response -in Redis, and surfaces any advisories to stdout + logs. +Fired on every Celery worker boot (see ``application/celery_init.py`` +``worker_ready`` handler) and on a 7h periodic schedule (see the +``version-check`` entry in ``application/api/user/tasks.py``). Posts +the running version + anonymous instance UUID to +``gptcloud.arc53.com/api/check``, caches the response in Redis, and +surfaces any advisories to stdout + logs. Design invariants — all enforced by a broad ``try/except`` at the top of :func:`run_check`: