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:
Joseph Schorr 2018-02-23 16:45:16 -05:00
parent d9015a1863
commit 8bc55a5676
21 changed files with 244 additions and 129 deletions

View file

@ -20,7 +20,8 @@ from data.database import (db, all_models, beta_classes, Role, TeamRole, Visibil
ExternalNotificationEvent, ExternalNotificationMethod, NotificationKind,
QuayRegion, QuayService, UserRegion, OAuthAuthorizationCode,
ServiceKeyApprovalType, MediaType, LabelSourceType, UserPromptKind,
RepositoryKind, TagKind, BlobPlacementLocation, User)
RepositoryKind, TagKind, BlobPlacementLocation, User,
DeletedNamespace)
from data import model
from data.queue import WorkQueue
from app import app, storage as store, tf
@ -893,8 +894,11 @@ def populate_database(minimal=False, with_storage=False):
model.repositoryactioncount.update_repository_score(to_count)
WHITELISTED_EMPTY_MODELS = ['DeletedNamespace']
def find_models_missing_data():
# As a sanity check we are going to make sure that all db tables have some data
# As a sanity check we are going to make sure that all db tables have some data, unless explicitly
# whitelisted.
models_missing_data = set()
for one_model in all_models:
if one_model in beta_classes:
@ -903,7 +907,8 @@ def find_models_missing_data():
try:
one_model.select().get()
except one_model.DoesNotExist:
models_missing_data.add(one_model.__name__)
if one_model.__name__ not in WHITELISTED_EMPTY_MODELS:
models_missing_data.add(one_model.__name__)
return models_missing_data