From b84fba6153dede6a74d63b11485b8fb8416a7500 Mon Sep 17 00:00:00 2001 From: Dunemask Date: Tue, 23 Jan 2024 13:43:13 -0700 Subject: [PATCH] [FEATURE] Initial Storage Configuration --- .../migrations/1_create_servers_table.sql | 1 + lib/database/queries/server-queries.js | 16 ++++++++++++ .../server-options/StorageOption.jsx | 26 +++++++++++++++++++ src/pages/CreateCoreOptions.jsx | 3 +++ 4 files changed, 46 insertions(+) create mode 100644 src/components/server-options/StorageOption.jsx diff --git a/lib/database/migrations/1_create_servers_table.sql b/lib/database/migrations/1_create_servers_table.sql index 3ef14ee..33ddc5a 100644 --- a/lib/database/migrations/1_create_servers_table.sql +++ b/lib/database/migrations/1_create_servers_table.sql @@ -7,6 +7,7 @@ CREATE TABLE servers ( server_type varchar(63) DEFAULT 'VANILLA', cpu varchar(63) DEFAULT '500', memory varchar(63) DEFAULT '512', + storage varchar(63) DEFAULT NULL, backup_enabled BOOLEAN DEFAULT FALSE, backup_host varchar(255) DEFAULT NULL, backup_bucket_path varchar(255) DEFAULT NULL, diff --git a/lib/database/queries/server-queries.js b/lib/database/queries/server-queries.js index 66300bc..aae5e6e 100644 --- a/lib/database/queries/server-queries.js +++ b/lib/database/queries/server-queries.js @@ -20,7 +20,9 @@ export async function createServerEntry(serverSpec) { host, version, serverType: server_type, + cpu, // TODO: Ignored for now by the K8S manifests memory, + storage, extraPorts: extra_ports, backupHost: backup_host, backupBucket: backup_bucket_path, @@ -33,7 +35,9 @@ export async function createServerEntry(serverSpec) { host, version, server_type, + cpu, // TODO: Ignored for now by the K8S manifests memory, + storage, extra_ports, backup_enabled: !!backup_interval ? true : null, // We already verified the payload, so any backup key will work backup_host, @@ -51,7 +55,9 @@ export async function createServerEntry(serverSpec) { host, version, server_type: serverType, + cpu, // TODO: Ignored for now by the K8S manifests memory, + storage, extra_ports: extraPorts, backup_enabled: backupEnabled, backup_host: backupHost, @@ -68,7 +74,9 @@ export async function createServerEntry(serverSpec) { host, version, serverType, + cpu, // TODO: Ignored for now by the K8S manifests memory, + storage, extraPorts, backupEnabled, backupHost, @@ -102,7 +110,9 @@ export async function getServerEntry(serverId) { host, version, server_type: serverType, + cpu, // TODO: Ignored for now by the K8S manifests memory, + storage, extra_ports: extraPorts, backup_enabled: backupEnabled, backup_host: backupHost, @@ -119,7 +129,9 @@ export async function getServerEntry(serverId) { host, version, serverType, + cpu, // TODO: Ignored for now by the K8S manifests memory, + storage, extraPorts, backupEnabled, backupHost, @@ -140,7 +152,9 @@ export async function modifyServerEntry(serverSpec) { host, version, serverType: server_type, + cpu, // TODO: Ignored for now by the K8S manifests memory, + // storage, // DO NOT INCLUDE THIS KEY, Not all storage providers in kubernetes allow for dynamically resizable PVCs extraPorts: extra_ports, backupEnabled: backup_enabled, backupHost: backup_host, @@ -157,7 +171,9 @@ export async function modifyServerEntry(serverSpec) { host, version, server_type, + cpu, // TODO: Ignored for now by the K8S manifests memory, + // storage, // DO NOT INCLUDE THIS KEY, Not all storage providers in kubernetes allow for dynamically resizable PVCs extra_ports, backup_enabled, backup_host, diff --git a/src/components/server-options/StorageOption.jsx b/src/components/server-options/StorageOption.jsx new file mode 100644 index 0000000..d1b7ed2 --- /dev/null +++ b/src/components/server-options/StorageOption.jsx @@ -0,0 +1,26 @@ +import TextField from "@mui/material/TextField"; +import MenuItem from "@mui/material/MenuItem"; + +const maxStorageSupported = 80; +export const storageOptions = new Array(2 * maxStorageSupported) + .fill(0) + .map((v, i) => (i + 1) * 0.5); + +export default function StorageOption(props) { + const { value, onChange } = props; + return ( + + No Storage + {storageOptions.map((o, i) => ( + {`${o} GB`} + ))} + + ); +} diff --git a/src/pages/CreateCoreOptions.jsx b/src/pages/CreateCoreOptions.jsx index 4d68121..4aaa74f 100644 --- a/src/pages/CreateCoreOptions.jsx +++ b/src/pages/CreateCoreOptions.jsx @@ -22,6 +22,7 @@ import MemoryOption, { memoryOptions, } from "@mcl/components/server-options/MemoryOption.jsx"; import ExtraPortsOption from "@mcl/components/server-options/ExtraPortsOption.jsx"; +import StorageOption from "@mcl/components/server-options/StorageOption.jsx"; import BackupHostOption from "@mcl/components/server-options/BackupHostOption.jsx"; import BackupBucketOption from "@mcl/components/server-options/BackupBucketOption.jsx"; @@ -36,6 +37,7 @@ const defaultServer = { serverType: serverTypeOptions[0], cpu: cpuOptions[0], memory: memoryOptions[2], // 1.5GB + storage: 0, extraPorts: [], }; @@ -99,6 +101,7 @@ export default function CreateCoreOptions() { /> +