From 2d082f18466d05938991a850f241e27736d4470e Mon Sep 17 00:00:00 2001 From: Dongjin Park Date: Tue, 29 Aug 2023 12:09:40 +0900 Subject: [PATCH] fix: avoid checking `max_vfolder_count` (#1397) Co-authored-by: Joongi Kim Backported-from: main Backported-to: 22.09 --- changes/1397.fix.md | 1 + src/ai/backend/manager/api/vfolder.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changes/1397.fix.md diff --git a/changes/1397.fix.md b/changes/1397.fix.md new file mode 100644 index 0000000000..b77a65e93b --- /dev/null +++ b/changes/1397.fix.md @@ -0,0 +1 @@ +Allow projcet vfolder creation regardless of the user (keypair) vfolder count limit diff --git a/src/ai/backend/manager/api/vfolder.py b/src/ai/backend/manager/api/vfolder.py index a5e9e03ab9..7c3ccff9b6 100644 --- a/src/ai/backend/manager/api/vfolder.py +++ b/src/ai/backend/manager/api/vfolder.py @@ -314,6 +314,7 @@ async def create(request: web.Request, params: Any) -> web.Response: resource_policy = request["keypair"]["resource_policy"] domain_name = request["user"]["domain_name"] group_id_or_name = params["group"] + ownership_type = "group" if group_id_or_name else "user" log.info( "VFOLDER.CREATE (email:{}, ak:{}, vf:{}, vfh:{}, umod:{}, perm:{})", request["user"]["email"], @@ -385,7 +386,7 @@ async def create(request: web.Request, params: Any) -> web.Response: if resource_policy["max_vfolder_count"] > 0: query = sa.select([sa.func.count()]).where(vfolders.c.user == user_uuid) result = await conn.scalar(query) - if result >= resource_policy["max_vfolder_count"]: + if result >= resource_policy["max_vfolder_count"] and ownership_type == "user": raise InvalidAPIParameters("You cannot create more vfolders.") # Limit vfolder size quota if it is larger than max_vfolder_size of the resource policy. @@ -447,7 +448,6 @@ async def create(request: web.Request, params: Any) -> web.Response: raise VFolderCreationFailed user_uuid = str(user_uuid) if group_id is None else None group_uuid = str(group_id) if group_id is not None else None - ownership_type = "group" if group_uuid is not None else "user" insert_values = { "id": folder_id.hex, "name": params["name"],