Merge pull request #4382 from wansir/master

Fix failed to delete workspace in multi-cluster enviroment
This commit is contained in:
KubeSphere CI Bot
2021-10-21 17:40:02 +08:00
committed by GitHub
2 changed files with 15 additions and 2 deletions

View File

@@ -477,8 +477,19 @@ func (r *Reconciler) deleteHelmRepos(ctx context.Context, ws string) error {
// deleteNamespacesInWorkspace Deletes the namespace associated with the workspace, which match the workspace label selector
func (r *Reconciler) deleteNamespacesInWorkspace(ctx context.Context, template *tenantv1alpha2.WorkspaceTemplate) error {
namespace := &corev1.Namespace{}
return r.DeleteAllOf(ctx, namespace, client.MatchingLabels{tenantv1alpha1.WorkspaceLabel: template.Name})
namespaceList := &corev1.NamespaceList{}
err := r.Client.List(ctx, namespaceList, client.MatchingLabels{tenantv1alpha1.WorkspaceLabel: template.Name})
if err != nil {
return err
}
for _, namespace := range namespaceList.Items {
err = r.Client.Delete(ctx, &namespace)
if err != nil {
return err
}
}
return nil
}
func workspaceRoleBindingChanger(workspaceRoleBinding *iamv1alpha2.WorkspaceRoleBinding, workspace, username, workspaceRoleName string) controllerutil.MutateFn {

View File

@@ -79,6 +79,8 @@ func init() {
&FederatedUserList{},
&FederatedGroup{},
&FederatedGroupList{},
&FederatedGroupBinding{},
&FederatedGroupBindingList{},
&FederatedWorkspace{},
&FederatedWorkspaceList{},
&FederatedWorkspaceRole{},