[FEATURE] Live Modifications, Host Safety, Minor Tweaks (#19)

Co-authored-by: Dunemask <dunemask@gmail.com>
Reviewed-on: https://gitea.dunemask.dev/elysium/minecluster/pulls/19
This commit is contained in:
dunemask 2024-02-13 05:09:18 +00:00
parent 0a0f9c8463
commit fc60df27ac
9 changed files with 154 additions and 31 deletions

View file

@ -165,7 +165,7 @@ export async function modifyServerEntry(serverSpec) {
id,
// ownerCairoId: owner_cairo_id, // DIsabled! If these becomes a reqest, please create a new function!
name,
host,
// host, // TODO: Can only be updated if service name is generic and non descriptive
version,
serverType: server_type,
cpu, // TODO: Ignored for now by the K8S manifests
@ -180,28 +180,66 @@ export async function modifyServerEntry(serverSpec) {
backupInterval: backup_interval,
} = serverSpec;
const q = updateWhereAllQuery(
table,
{
const q =
updateWhereAllQuery(
table,
{
name,
// host, // TODO: Can only be updated if service name is generic and non descriptive
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,
backup_bucket_path,
backup_id,
backup_key,
backup_interval,
},
{ id },
) + ` RETURNING *;`;
try {
const entries = await pg.query(q);
const {
name,
host,
host, // Should always read the database value
server_type: serverType,
storage,
extra_ports: extraPorts,
backup_enabled: backupEnabled,
backup_host: backupHost,
backup_bucket_path: backupPath,
backup_id: backupId,
backup_key: backupKey,
backup_interval: backupInterval,
} = entries[0];
const mclName = getMclName(host, id);
return {
name, // Could change
mclName, // Shouldn't change
id, // Won't change
// host, // TODO: Can only be updated if service name is generic and non descriptive
version,
server_type,
serverType,
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,
backup_bucket_path,
backup_id,
backup_key,
backup_interval,
},
{ id },
);
return pg.query(q);
storage,
extraPorts,
backupEnabled,
backupHost,
backupPath,
backupId,
backupKey,
backupInterval,
};
} catch (e) {
asExpressClientError(e);
}
}
export async function getServerEntries() {