Skip to content

Commit

Permalink
fix: provide deprecation msg to max_vfolder_size graphene field (#1644
Browse files Browse the repository at this point in the history
)

Backported-from: main
Backported-to: 23.09
  • Loading branch information
fregataa committed Oct 23, 2023
1 parent e07a4b6 commit 2a1cc67
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions changes/1644.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Set deprecation message to `max_vfolder_size` graphene field. Set `max_vfolder_count` and `max_quota_scope_size` graphene fields optional. Update VFolder update API to use renewed column name `max_quota_scope_size`.
8 changes: 4 additions & 4 deletions src/ai/backend/manager/api/vfolder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,10 +1058,10 @@ async def update_quota(request: web.Request, params: Any) -> web.Response:
if len(entries) == 0:
raise VFolderNotFound(extra_data=params["id"])

# Limit vfolder size quota if it is larger than max_vfolder_size of the resource policy.
max_vfolder_size = resource_policy.get("max_vfolder_size", 0)
if max_vfolder_size > 0 and (quota <= 0 or quota > max_vfolder_size):
quota = max_vfolder_size
# Limit vfolder size quota if it is larger than max_quota_scope_size of the resource policy.
max_quota_scope_size = resource_policy.get("max_quota_scope_size", 0)
if max_quota_scope_size > 0 and (quota <= 0 or quota > max_quota_scope_size):
quota = max_quota_scope_size

async with root_ctx.storage_manager.request(
proxy_name,
Expand Down
20 changes: 14 additions & 6 deletions src/ai/backend/manager/models/resource_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ class UserResourcePolicy(graphene.ObjectType):
id = graphene.ID(required=True)
name = graphene.String(required=True)
created_at = GQLDateTime(required=True)
max_vfolder_size = BigInt()
max_vfolder_count = graphene.Int()
max_vfolder_size = BigInt(deprecation_reason="Deprecated since 23.09.1")
max_quota_scope_size = BigInt()

@classmethod
def from_row(
Expand Down Expand Up @@ -488,11 +490,13 @@ async def batch_load_by_user(


class CreateUserResourcePolicyInput(graphene.InputObjectType):
max_vfolder_size = BigInt(required=True)
max_vfolder_count = graphene.Int()
max_quota_scope_size = BigInt()


class ModifyUserResourcePolicyInput(graphene.InputObjectType):
max_vfolder_size = BigInt(required=True)
max_vfolder_count = graphene.Int()
max_quota_scope_size = BigInt()


class CreateUserResourcePolicy(graphene.Mutation):
Expand Down Expand Up @@ -586,7 +590,9 @@ class ProjectResourcePolicy(graphene.ObjectType):
id = graphene.ID(required=True)
name = graphene.String(required=True)
created_at = GQLDateTime(required=True)
max_vfolder_size = BigInt()
max_vfolder_count = graphene.Int()
max_vfolder_size = BigInt(deprecation_reason="Deprecated since 23.09.1")
max_quota_scope_size = BigInt()

@classmethod
def from_row(
Expand Down Expand Up @@ -657,11 +663,13 @@ async def batch_load_by_project(


class CreateProjectResourcePolicyInput(graphene.InputObjectType):
max_vfolder_size = BigInt(required=True)
max_vfolder_count = graphene.Int()
max_quota_scope_size = BigInt()


class ModifyProjectResourcePolicyInput(graphene.InputObjectType):
max_vfolder_size = BigInt(required=True)
max_vfolder_count = graphene.Int()
max_quota_scope_size = BigInt()


class CreateProjectResourcePolicy(graphene.Mutation):
Expand Down

0 comments on commit 2a1cc67

Please sign in to comment.