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
|
|
@ -2,7 +2,7 @@ import features
|
|||
|
||||
from flask import request
|
||||
|
||||
from app import all_queues, userfiles
|
||||
from app import all_queues, userfiles, namespace_gc_queue
|
||||
from auth.permissions import ReadRepositoryPermission, ModifyRepositoryPermission, AdministerRepositoryPermission
|
||||
from data import model, database
|
||||
from endpoints.api.build import get_job_config, _get_build_status
|
||||
|
|
@ -141,9 +141,9 @@ class PreOCIModel(SuperuserDataInterface):
|
|||
|
||||
return Organization(org.username, org.email)
|
||||
|
||||
def delete_organization(self, name):
|
||||
def mark_organization_for_deletion(self, name):
|
||||
org = model.organization.get_organization(name)
|
||||
model.user.delete_user(org, all_queues)
|
||||
model.user.mark_namespace_for_deletion(org, all_queues, namespace_gc_queue, force=True)
|
||||
|
||||
def take_ownership(self, namespace, authed_user):
|
||||
entity = model.user.get_user_or_org(namespace)
|
||||
|
|
@ -172,9 +172,9 @@ class PreOCIModel(SuperuserDataInterface):
|
|||
user = model.user.get_nonrobot_user(username)
|
||||
model.user.change_password(user, password)
|
||||
|
||||
def delete_user(self, username):
|
||||
def mark_user_for_deletion(self, username):
|
||||
user = model.user.get_nonrobot_user(username)
|
||||
model.user.delete_user(user, all_queues, force=True)
|
||||
model.user.mark_namespace_for_deletion(user, all_queues, namespace_gc_queue, force=True)
|
||||
|
||||
def create_reset_password_email_code(self, email):
|
||||
code = model.user.create_reset_password_email_code(email)
|
||||
|
|
|
|||
Reference in a new issue