Make namespace deletion asynchronous
Instead of deleting a namespace synchronously as before, we now mark the namespace for deletion, disable it, and rename it. A worker then comes along and deletes the namespace in the background. This results in a *significantly* better user experience, as the namespace deletion operation now "completes" in under a second, where before it could take 10s of minutes at the worse. Fixes https://jira.coreos.com/browse/QUAY-838
This commit is contained in:
parent
d9015a1863
commit
8bc55a5676
21 changed files with 244 additions and 129 deletions
28
workers/namespacegcworker.py
Normal file
28
workers/namespacegcworker.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
import logging
|
||||
import time
|
||||
|
||||
from app import app, namespace_gc_queue, all_queues
|
||||
from data import model
|
||||
from workers.queueworker import QueueWorker, JobException
|
||||
from util.log import logfile_path
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
POLL_PERIOD_SECONDS = 60
|
||||
|
||||
|
||||
class NamespaceGCWorker(QueueWorker):
|
||||
""" Worker which cleans up namespaces enqueued to be GCed.
|
||||
"""
|
||||
def process_queue_item(self, job_details):
|
||||
logger.debug('Got namespace GC queue item: %s', job_details)
|
||||
marker_id = job_details['marker_id']
|
||||
model.user.delete_namespace_via_marker(marker_id, all_queues)
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.config.fileConfig(logfile_path(debug=False), disable_existing_loggers=False)
|
||||
|
||||
logger.debug('Starting namespace GC worker')
|
||||
worker = NamespaceGCWorker(namespace_gc_queue, poll_period_seconds=POLL_PERIOD_SECONDS)
|
||||
worker.start()
|
Reference in a new issue