Skip to content

Commit

Permalink
fix: set Max Network Count field to project resource policy (#2989)
Browse files Browse the repository at this point in the history
<!--
Please precisely, concisely, and concretely describe what this PR changes, the rationale behind codes,
and how it affects the users and other developers.
-->

### This PR resolves [#2988](#2988) issue.

Related PR: [Core #2857](lablup/backend.ai#2857)

Fixes an issue where the addition of the `max_network_count` field to the Project resource policy prevented the creation of a new project resource policy due to the undefinedType input of that field.

**Changes:**
- Since core version "24.12.0", `max_network_count` field was added to the proeject resource policy.

**Checklist:** (if applicable)

- [ ] Mention to the original issue
- [ ] Documentation
- [ ] Minium required manager version
- [ ] Specific setting for review (eg., KB link, endpoint or how to setup)
- [ ] Minimum requirements to check during review
- [ ] Test case(s) to demonstrate the difference of before/after
  • Loading branch information
ironAiken2 committed Dec 26, 2024
1 parent 84f2449 commit 84ed0b5
Show file tree
Hide file tree
Showing 25 changed files with 205 additions and 48 deletions.
107 changes: 105 additions & 2 deletions react/data/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ type Queries {

"""Added in 24.03.0."""
model_cards(filter: String, order: String, offset: Int, before: String, after: String, first: Int, last: Int): ModelCardConnection

"""Added in 24.12.0."""
network(id: String!): NetworkNode

"""Added in 24.12.0."""
networks(filter: String, order: String, offset: Int, before: String, after: String, first: Int, last: Int): NetworkConnection
}

"""
Expand Down Expand Up @@ -1023,6 +1029,11 @@ type ProjectResourcePolicy {
"""
max_quota_scope_size: BigInt
max_vfolder_size: BigInt @deprecated(reason: "Deprecated since 23.09.2.")

"""
Added in 24.12.0. Limitation of the number of networks created on behalf of project.
"""
max_network_count: Int
}

type ResourcePreset {
Expand Down Expand Up @@ -1368,7 +1379,10 @@ type Endpoint implements Item {
environ: JSONString
name: String
resource_opts: JSONString
desired_session_count: Int

"""Added in 24.12.0. Replaces `desired_session_count`."""
replicas: Int
desired_session_count: Int @deprecated(reason: "Deprecated since 24.12.0. Use `replicas` instead.")
cluster_mode: String
cluster_size: Int
open_to_public: Boolean
Expand All @@ -1382,6 +1396,9 @@ type Endpoint implements Item {
status: String
lifecycle_stage: String
errors: [InferenceSessionError!]!

"""Added in 24.12.0."""
live_stat: JSONString
}

"""Added in 24.03.5."""
Expand All @@ -1399,6 +1416,9 @@ type Routing implements Item {
traffic_ratio: Float
created_at: DateTime
error_data: JSONString

"""Added in 24.12.0."""
live_stat: JSONString
}

type InferenceSessionError {
Expand Down Expand Up @@ -1595,6 +1615,42 @@ type ModelCardEdge {
cursor: String!
}

"""Added in 24.12.0."""
type NetworkNode implements Node {
"""The ID of the object"""
id: ID!
row_id: UUID
name: String
ref_name: String
driver: String
project: UUID
domain_name: String
options: JSONString
created_at: DateTime
updated_at: DateTime
}

"""Added in 24.12.0."""
type NetworkConnection {
"""Pagination data for this connection."""
pageInfo: PageInfo!

"""Contains the nodes in this connection."""
edges: [NetworkEdge]!

"""Total count of the GQL nodes of the query."""
count: Int
}

"""Added in 24.12.0. A Relay edge containing a `Network` and its cursor."""
type NetworkEdge {
"""The item at the end of the edge"""
node: NetworkNode

"""A cursor for use in pagination"""
cursor: String!
}

"""All available GraphQL mutations."""
type Mutations {
modify_agent(id: String!, props: ModifyAgentInput!): ModifyAgent
Expand Down Expand Up @@ -1799,6 +1855,15 @@ type Mutations {

"""Added in 24.09.0."""
check_and_transit_session_status(input: CheckAndTransitStatusInput!): CheckAndTransitStatus

"""Added in 24.12.0."""
create_network(driver: String, name: String!, project_id: UUID!): CreateNetwork

"""Added in 24.12.0."""
modify_network(network: String!, props: ModifyNetworkInput!): ModifyNetwork

"""Added in 24.12.0."""
delete_network(network: String!): DeleteNetwork
}

type ModifyAgent {
Expand Down Expand Up @@ -2310,6 +2375,11 @@ input CreateProjectResourcePolicyInput {
"""
max_quota_scope_size: BigInt
max_vfolder_size: BigInt @deprecated(reason: "Deprecated since 23.09.2.")

"""
Added in 24.12.0. Limitation of the number of networks created on behalf of project. Set as -1 to allow creating unlimited networks.
"""
max_network_count: Int
}

type ModifyProjectResourcePolicy {
Expand All @@ -2328,6 +2398,11 @@ input ModifyProjectResourcePolicyInput {
"""
max_quota_scope_size: BigInt
max_vfolder_size: BigInt @deprecated(reason: "Deprecated since 23.09.2.")

"""
Added in 24.12.0. Limitation of the number of networks created on behalf of project. Set as -1 to allow creating unlimited networks.
"""
max_network_count: Int
}

type DeleteProjectResourcePolicy {
Expand Down Expand Up @@ -2555,7 +2630,10 @@ input ModifyEndpointInput {
resource_opts: JSONString
cluster_mode: String
cluster_size: Int
desired_session_count: Int

"""Added in 24.12.0. Replaces `desired_session_count`."""
replicas: Int
desired_session_count: Int @deprecated(reason: "Deprecated since 24.12.0. Use `replicas` instead.")
image: ImageRefType
name: String
resource_group: String
Expand Down Expand Up @@ -2610,4 +2688,29 @@ type CheckAndTransitStatus {
input CheckAndTransitStatusInput {
ids: [GlobalIDField]!
client_mutation_id: String
}

"""Added in 24.12.0."""
type CreateNetwork {
ok: Boolean
msg: String
network: NetworkNode
}

"""Added in 24.12.0."""
type ModifyNetwork {
ok: Boolean
msg: String
network: NetworkNode
}

"""Added in 24.12.0."""
input ModifyNetworkInput {
name: String!
}

"""Added in 24.12.0."""
type DeleteNetwork {
ok: Boolean
msg: String
}
65 changes: 40 additions & 25 deletions react/src/components/ProjectResourcePolicyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const ProjectResourcePolicyList: React.FC<
'max-vfolder-count-in-user-and-project-resource-policy',
);
const supportMaxQuotaScopeSize = baiClient?.supports('max-quota-scope-size');
const supportMaxNetworkCount = baiClient?.supports('max_network_count');

const { project_resource_policies } =
useLazyLoadQuery<ProjectResourcePolicyListQuery>(
Expand All @@ -83,6 +84,7 @@ const ProjectResourcePolicyList: React.FC<
max_vfolder_count @since(version: "23.09.6")
max_quota_scope_size @since(version: "23.09.2")
# ---------------- END ---------------------
max_network_count @since(version: "24.12.0")
...ProjectResourcePolicySettingModalFragment
}
}
Expand Down Expand Up @@ -115,31 +117,44 @@ const ProjectResourcePolicyList: React.FC<
fixed: 'left',
sorter: (a, b) => localeCompare(a?.name, b?.name),
},
supportMaxVfolderCount && {
title: t('resourcePolicy.MaxVFolderCount'),
dataIndex: 'max_vfolder_count',
key: 'max_vfolder_count',
render: (text: ProjectResourcePolicies) =>
_.toNumber(text) === 0 ? '∞' : text,
sorter: (a, b) =>
numberSorterWithInfinityValue(
a?.max_vfolder_count,
b?.max_vfolder_count,
0,
),
},
supportMaxQuotaScopeSize && {
title: t('resourcePolicy.MaxQuotaScopeSize'),
dataIndex: 'max_quota_scope_size',
key: 'max_quota_scope_size',
render: (text) => (text === -1 ? '∞' : bytesToGB(text)),
sorter: (a, b) =>
numberSorterWithInfinityValue(
a?.max_quota_scope_size,
b?.max_quota_scope_size,
-1,
),
},
supportMaxVfolderCount
? {
title: t('resourcePolicy.MaxVFolderCount'),
dataIndex: 'max_vfolder_count',
key: 'max_vfolder_count',
render: (text: ProjectResourcePolicies) =>
_.toNumber(text) === 0 ? '∞' : text,
sorter: (a, b) =>
numberSorterWithInfinityValue(
a?.max_vfolder_count,
b?.max_vfolder_count,
0,
),
}
: {},
supportMaxQuotaScopeSize
? {
title: t('resourcePolicy.MaxQuotaScopeSize'),
dataIndex: 'max_quota_scope_size',
key: 'max_quota_scope_size',
render: (text) => (text === -1 ? '∞' : bytesToGB(text)),
sorter: (a, b) =>
numberSorterWithInfinityValue(
a?.max_quota_scope_size,
b?.max_quota_scope_size,
-1,
),
}
: {},
supportMaxNetworkCount
? {
title: t('resourcePolicy.MaxNetworkCount'),
dataIndex: 'max_network_count',
key: 'max_network_count',
render: (text) => (text === -1 ? '∞' : text),
sorter: (a, b) => true,
}
: {},
{
title: 'ID',
dataIndex: 'id',
Expand Down
17 changes: 17 additions & 0 deletions react/src/components/ProjectResourcePolicySettingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const ProjectResourcePolicySettingModal: React.FC<Props> = ({
'max-vfolder-count-in-user-and-project-resource-policy',
);
const supportMaxQuotaScopeSize = baiClient?.supports('max-quota-scope-size');
const supportMaxNetworkCount = baiClient?.supports('max_network_count');

const projectResourcePolicy = useFragment(
graphql`
Expand All @@ -61,6 +62,7 @@ const ProjectResourcePolicySettingModal: React.FC<Props> = ({
max_vfolder_count @since(version: "23.09.6")
max_quota_scope_size @since(version: "23.09.2")
# ---------------- END ---------------------
max_network_count @since(version: "24.12.0")
}
`,
projectResourcePolicyFrgmt,
Expand Down Expand Up @@ -103,6 +105,7 @@ const ProjectResourcePolicySettingModal: React.FC<Props> = ({
// Initialize unlimited values as a default when creating a new policy.\
max_vfolder_count: 0,
max_quota_scope_size: -1,
max_network_count: -1,
};
}
let maxQuotaScopeSize = projectResourcePolicy?.max_quota_scope_size;
Expand Down Expand Up @@ -134,13 +137,17 @@ const ProjectResourcePolicySettingModal: React.FC<Props> = ({
values?.max_quota_scope_size === -1
? -1
: GBToBytes(values?.max_quota_scope_size),
max_network_count: values?.max_network_count || -1,
};
if (!supportMaxVfolderCount) {
delete props.max_vfolder_count;
}
if (!supportMaxQuotaScopeSize) {
delete props.max_quota_scope_size;
}
if (!supportMaxNetworkCount) {
delete props.max_network_count;
}
if (projectResourcePolicy === null) {
commitCreateProjectResourcePolicy({
variables: {
Expand Down Expand Up @@ -272,6 +279,16 @@ const ProjectResourcePolicySettingModal: React.FC<Props> = ({
<InputNumber min={0} addonAfter="GB" style={{ width: '100%' }} />
</FormItemWithUnlimited>
) : null}
{supportMaxNetworkCount ? (
<FormItemWithUnlimited
name={'max_network_count'}
unlimitedValue={-1}
label={t('resourcePolicy.MaxNetworkCount')}
style={{ width: '100%', margin: 0 }}
>
<InputNumber min={0} style={{ width: '100%' }} />
</FormItemWithUnlimited>
) : null}
</Flex>
</Form>
</BAIModal>
Expand Down
3 changes: 2 additions & 1 deletion resources/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,8 @@
"NoDataToExport": "Die Daten für den CSV-Extrakt sind nicht vorhanden.",
"ExportCSV": "CSV exportieren",
"Tools": "Werkzeuge",
"MemorySizeExceedsLimit": "Die Speichergröße sollte weniger als 300 PiB betragen"
"MemorySizeExceedsLimit": "Die Speichergröße sollte weniger als 300 PiB betragen",
"MaxNetworkCount": "Maximale Netzwerkanzahl"
},
"registry": {
"Hostname": "Hostname",
Expand Down
3 changes: 2 additions & 1 deletion resources/i18n/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,8 @@
"NoDataToExport": "Τα δεδομένα για το απόσπασμα CSV δεν υπάρχουν.",
"ExportCSV": "εξαγωγή CSV",
"Tools": "Εργαλεία",
"MemorySizeExceedsLimit": "Το μέγεθος της μνήμης πρέπει να είναι μικρότερο από 300 PiB"
"MemorySizeExceedsLimit": "Το μέγεθος της μνήμης πρέπει να είναι μικρότερο από 300 PiB",
"MaxNetworkCount": "Μέγιστος αριθμός δικτύου"
},
"registry": {
"Hostname": "Όνομα κεντρικού υπολογιστή",
Expand Down
3 changes: 2 additions & 1 deletion resources/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,8 @@
"NoDataToExport": "The data for the CSV extract does not exist.",
"ExportCSV": "export CSV",
"Tools": "Tools",
"MemorySizeExceedsLimit": "Memory size should be less than 300 PiB"
"MemorySizeExceedsLimit": "Memory size should be less than 300 PiB",
"MaxNetworkCount": "Max Network Count"
},
"registry": {
"Hostname": "Hostname",
Expand Down
3 changes: 2 additions & 1 deletion resources/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,8 @@
"NoDataToExport": "Los datos para el extracto CSV no existen.",
"ExportCSV": "exportar CSV",
"Tools": "Herramientas",
"MemorySizeExceedsLimit": "El tamaño de la memoria debe ser inferior a 300 PiB"
"MemorySizeExceedsLimit": "El tamaño de la memoria debe ser inferior a 300 PiB",
"MaxNetworkCount": "Recuento máximo de red"
},
"resourcePreset": {
"AboutToDeletePreset": "Está a punto de borrar este preajuste:",
Expand Down
3 changes: 2 additions & 1 deletion resources/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,8 @@
"NoDataToExport": "CSV-otteen tietoja ei ole olemassa.",
"ExportCSV": "vie CSV",
"Tools": "Työkalut",
"MemorySizeExceedsLimit": "Muistin koon tulee olla alle 300 PiB"
"MemorySizeExceedsLimit": "Muistin koon tulee olla alle 300 PiB",
"MaxNetworkCount": "Verkkojen enimmäismäärä"
},
"resourcePreset": {
"AboutToDeletePreset": "Olet poistamassa tätä esiasetusta:",
Expand Down
3 changes: 2 additions & 1 deletion resources/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,8 @@
"NoDataToExport": "Les données pour l'extrait CSV n'existent pas.",
"ExportCSV": "exporter au format CSV",
"Tools": "Outils",
"MemorySizeExceedsLimit": "La taille de la mémoire doit être inférieure à 300 PiB"
"MemorySizeExceedsLimit": "La taille de la mémoire doit être inférieure à 300 PiB",
"MaxNetworkCount": "Nombre maximum de réseaux"
},
"registry": {
"Hostname": "Nom d'hôte",
Expand Down
3 changes: 2 additions & 1 deletion resources/i18n/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,8 @@
"NoDataToExport": "Data untuk ekstrak CSV tidak ada.",
"ExportCSV": "ekspor CSV",
"Tools": "Peralatan",
"MemorySizeExceedsLimit": "Ukuran memori harus kurang dari 300 PiB"
"MemorySizeExceedsLimit": "Ukuran memori harus kurang dari 300 PiB",
"MaxNetworkCount": "Jumlah Jaringan Maks"
},
"registry": {
"Hostname": "Nama host",
Expand Down
Loading

0 comments on commit 84ed0b5

Please sign in to comment.