From 132e25b7f2adef058fd324f6d1983decb0de5ec6 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Wed, 10 Jun 2026 16:43:03 +0000 Subject: [PATCH] add failure path to approveResources if there was an error retrieving pool state from proxmox or fabric --- src/backends/pve.js | 5 ++++- src/routes/cluster/disk.js | 2 -- src/utils.js | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/backends/pve.js b/src/backends/pve.js index fc539f6..9fce1bb 100644 --- a/src/backends/pve.js +++ b/src/backends/pve.js @@ -254,7 +254,10 @@ export default class PVE extends PVE_BACKEND { // only add type if it is vm or ct (ie has vmid) if (resource.vmid) { const instance = await this.getInstance(resource.node, resource.vmid); - if (instance) { + if (instance === null) { + return null; + } + else { instance.node = resource.node; resources[resource.vmid] = instance; } diff --git a/src/routes/cluster/disk.js b/src/routes/cluster/disk.js index 9e98b7e..6ed9cc4 100644 --- a/src/routes/cluster/disk.js +++ b/src/routes/cluster/disk.js @@ -336,8 +336,6 @@ router.post("/:disk/create", async (req, res) => { size: req.body.size, iso: req.body.iso }; - - console.log(req.cookies) // attempt to parse user from username const userObj = global.utils.getUserObjFromUsername(req.cookies.username); diff --git a/src/utils.js b/src/utils.js index fd63305..f45d49c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -123,6 +123,9 @@ export async function getPoolResources (req, pool) { } const configs = await global.pve.getPoolResources(req.cookies, pool); + if (configs === null) { + return null; + } for (const vmid in configs) { const config = configs[vmid]; @@ -232,6 +235,11 @@ export async function approveResources (req, user, node, pool, request) { const poolResources = await getPoolResources(req, pool); const reason = {}; + if (poolResources === null) { + reason["server"] = "error in retrieving pool resource state"; + return {approved: false, reason}; + } + for (const key in request) { // if requested resource is not specified in user resources, assume it's not allowed if (!(key in poolResources)) {