From f2f4f45097645a38dbae8b1d8125f4530f5009b3 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Tue, 7 Oct 2025 21:36:36 +0000 Subject: [PATCH] fix bug with unconverted resource types --- src/routes/cluster.js | 6 +++--- src/utils.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/routes/cluster.js b/src/routes/cluster.js index 0f6598b..0b740e5 100644 --- a/src/routes/cluster.js +++ b/src/routes/cluster.js @@ -294,11 +294,11 @@ router.post(`${basePath}/create`, async (req, res) => { // setup request const request = { cores: Number(params.cores), - memory: Number(params.memory) + memory: Number(params.memory) * 1024 ** 2 }; if (params.type === "lxc") { - request.swap = params.swap; - request[params.rootfslocation] = params.rootfssize; + request.swap = Number(params.swap) * 1024 ** 2; + request[params.rootfslocation] = params.rootfssize * 1024 ** 3; } for (const key of Object.keys(user.templates.instances[params.type])) { const item = user.templates.instances[params.type][key]; diff --git a/src/utils.js b/src/utils.js index d8026f9..af35a4c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -248,8 +248,8 @@ export async function approveResources (req, user, request, node) { return false; } } - // if either the requested or avail resource is NaN, block - else if (isNaN(resourceData.avail) || isNaN(request[key])) { + // if either the requested or avail resource is not strictly a number, block + else if (typeof (resourceData.avail) !== "number" || typeof (request[key]) !== "number") { approved = false; return false; }