1
0
mirror of https://github.com/quay/quay.git synced 2025-11-07 15:46:28 +03:00

Revert workqueue refactor (#1456)

Currently the prometheus and GC workers are not running correctly.
Reverting the following commits:
- 4e1a985e70
- dac183a1ef
- 68a0d9eaf0
- af1aacea08
- f334b80098
This commit is contained in:
Brandon Caton
2022-07-22 13:11:39 -04:00
committed by GitHub
parent d37dd766ac
commit 9eb4fb6aa4
51 changed files with 280 additions and 322 deletions

View File

@@ -3,9 +3,9 @@ import time
from datetime import timedelta, datetime
from app import app
from data.database import UseThenDisconnect
from data.queue import delete_expired
from singletons.config import app_config
from workers.worker import Worker
from workers.gunicorn_worker import GunicornWorker
@@ -15,7 +15,7 @@ logger = logging.getLogger(__name__)
DELETION_DATE_THRESHOLD = timedelta(days=1)
DELETION_COUNT_THRESHOLD = 50
BATCH_SIZE = 500
QUEUE_CLEANUP_FREQUENCY = app_config.get("QUEUE_CLEANUP_FREQUENCY", 60 * 60 * 24)
QUEUE_CLEANUP_FREQUENCY = app.config.get("QUEUE_CLEANUP_FREQUENCY", 60 * 60 * 24)
class QueueCleanupWorker(Worker):
@@ -27,7 +27,7 @@ class QueueCleanupWorker(Worker):
"""
Performs garbage collection on the queueitem table.
"""
with UseThenDisconnect(app_config):
with UseThenDisconnect(app.config):
while True:
# Find all queue items older than the threshold (typically a week) and delete them.
expiration_threshold = datetime.now() - DELETION_DATE_THRESHOLD
@@ -38,7 +38,7 @@ class QueueCleanupWorker(Worker):
return
def create_gunicorn_worker() -> GunicornWorker:
def create_gunicorn_worker():
"""
follows the gunicorn application factory pattern, enabling
a quay worker to run as a gunicorn worker thread.
@@ -47,12 +47,12 @@ def create_gunicorn_worker() -> GunicornWorker:
utilizing this method will enforce a 1:1 quay worker to gunicorn worker ratio.
"""
worker = GunicornWorker(__name__, QueueCleanupWorker(), True)
worker = GunicornWorker(__name__, app, QueueCleanupWorker(), True)
return worker
if __name__ == "__main__":
if app_config.get("ACCOUNT_RECOVERY_MODE", False):
if app.config.get("ACCOUNT_RECOVERY_MODE", False):
logger.debug("Quay running in account recovery mode")
while True:
time.sleep(100000)