From 8e4b2c4f643d18fa7076c50e9c3aeb50801a09e6 Mon Sep 17 00:00:00 2001 From: ImMin5 Date: Fri, 19 Apr 2024 10:42:24 +0900 Subject: [PATCH] fix: fix delete workspace error when service account doesn't exist Signed-off-by: ImMin5 --- src/spaceone/identity/service/workspace_service.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/spaceone/identity/service/workspace_service.py b/src/spaceone/identity/service/workspace_service.py index 950d08ef..dfca3784 100644 --- a/src/spaceone/identity/service/workspace_service.py +++ b/src/spaceone/identity/service/workspace_service.py @@ -32,6 +32,7 @@ def __init__(self, *args, **kwargs): self.domain_mgr = DomainManager() self.resource_mgr = ResourceManager() self.workspace_mgr = WorkspaceManager() + self.service_account_mgr = ServiceAccountManager() @transaction(permission="identity:Workspace.write", role_types=["DOMAIN_ADMIN"]) @convert_model @@ -102,13 +103,13 @@ def delete(self, params: WorkspaceDeleteRequest) -> None: # Check is managed resource self.resource_mgr.check_is_managed_resource_by_trusted_account(workspace_vo) - service_account_vos = self.workspace_mgr.filter_workspaces( + service_account_vos = self.service_account_mgr.filter_service_accounts( domain_id=domain_id, workspace_id=workspace_id ) if params.force: self._delete_related_resources_in_workspace(workspace_vo) - elif service_account_vos.count() > 0: + elif len(service_account_vos) > 0: raise ERROR_UNKNOWN( message=f"Please delete service accounts in workspace ({workspace_id})" )