From 478a25c9e0ea8070253fc9e70d688a92ad05d41b Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Thu, 18 May 2023 20:19:01 +0000 Subject: [PATCH] fix issue in swap handling in /instance/resources Signed-off-by: Arthur Lu --- main.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 471b827..2a60fcf 100644 --- a/main.js +++ b/main.js @@ -466,7 +466,7 @@ app.post("/api/instance/resources", async (req, res) => { cores: Number(req.body.cores) - Number(currentConfig.data.data.cores), memory: Number(req.body.memory) - Number(currentConfig.data.data.memory) }; - if (type === "lxc") { + if (req.body.type === "lxc") { request.swap = Number(req.body.swap) - Number(currentConfig.data.data.swap); } // check resource approval @@ -476,7 +476,11 @@ app.post("/api/instance/resources", async (req, res) => { return; } // setup action - let action = JSON.stringify({ cores: req.body.cores, memory: req.body.memory }); + let action = { cores: req.body.cores, memory: req.body.memory }; + if (req.body.type === "lxc") { + action.swap = Number(req.body.swap); + } + action = JSON.stringify(action); let method = req.body.type === "qemu" ? "POST" : "PUT"; // commit action let result = await requestPVE(`${vmpath}/config`, method, req.cookies, action, pveAPIToken);