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
|
@ -189,59 +189,21 @@ function(ApiService, CookieService, $rootScope, Config, $location, $timeout) {
|
|||
}
|
||||
|
||||
var errorDisplay = ApiService.errorDisplay('Could not delete namespace', callback);
|
||||
var deleteNamespaceItself = function() {
|
||||
info.progress = 1;
|
||||
info.progressMessage = 'Deleting namespace...';
|
||||
var cb = function(resp) {
|
||||
userService.load(function(currentUser) {
|
||||
callback(true);
|
||||
$location.path('/');
|
||||
});
|
||||
}
|
||||
var cb = function(resp) {
|
||||
userService.load(function(currentUser) {
|
||||
callback(true);
|
||||
$location.path('/');
|
||||
});
|
||||
}
|
||||
|
||||
if (info.user) {
|
||||
ApiService.deleteCurrentUser().then(cb, errorDisplay)
|
||||
} else {
|
||||
var delParams = {
|
||||
'orgname': info.organization.name
|
||||
};
|
||||
ApiService.deleteAdminedOrganization(null, delParams).then(cb, errorDisplay);
|
||||
}
|
||||
};
|
||||
|
||||
var repoIndex = 0;
|
||||
var repositories = null;
|
||||
var deleteAllRepos = function() {
|
||||
if (repoIndex >= repositories.length) {
|
||||
deleteNamespaceItself();
|
||||
return;
|
||||
}
|
||||
|
||||
var repoParams = {
|
||||
'repository': namespace + '/' + repositories[repoIndex]['name']
|
||||
if (info.user) {
|
||||
ApiService.deleteCurrentUser().then(cb, errorDisplay)
|
||||
} else {
|
||||
var delParams = {
|
||||
'orgname': info.organization.name
|
||||
};
|
||||
|
||||
info.progress = repoIndex / repositories.length;
|
||||
info.progressMessage = 'Deleting repository ' + repoParams['repository'] + '...';
|
||||
|
||||
ApiService.deleteRepository(null, repoParams).then(function() {
|
||||
repoIndex++;
|
||||
deleteAllRepos();
|
||||
}, errorDisplay);
|
||||
};
|
||||
|
||||
// First delete each repo for the namespace, updating the info so it can show a progress bar.
|
||||
// This is not strictly necessary (as the namespace delete call will do it as well), but it is
|
||||
// a better user experience.
|
||||
var params = {
|
||||
'namespace': namespace,
|
||||
'public': false
|
||||
};
|
||||
|
||||
ApiService.listRepos(null, params).then(function(resp) {
|
||||
repositories = resp['repositories'];
|
||||
deleteAllRepos();
|
||||
}, errorDisplay);
|
||||
ApiService.deleteAdminedOrganization(null, delParams).then(cb, errorDisplay);
|
||||
}
|
||||
};
|
||||
|
||||
userService.currentUser = function() {
|
||||
|
|
Reference in a new issue