add failure path to approveResources if there was an error retrieving pool state from proxmox or fabric
This commit is contained in:
+4
-1
@@ -254,7 +254,10 @@ export default class PVE extends PVE_BACKEND {
|
|||||||
// only add type if it is vm or ct (ie has vmid)
|
// only add type if it is vm or ct (ie has vmid)
|
||||||
if (resource.vmid) {
|
if (resource.vmid) {
|
||||||
const instance = await this.getInstance(resource.node, resource.vmid);
|
const instance = await this.getInstance(resource.node, resource.vmid);
|
||||||
if (instance) {
|
if (instance === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
instance.node = resource.node;
|
instance.node = resource.node;
|
||||||
resources[resource.vmid] = instance;
|
resources[resource.vmid] = instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -336,8 +336,6 @@ router.post("/:disk/create", async (req, res) => {
|
|||||||
size: req.body.size,
|
size: req.body.size,
|
||||||
iso: req.body.iso
|
iso: req.body.iso
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(req.cookies)
|
|
||||||
|
|
||||||
// attempt to parse user from username
|
// attempt to parse user from username
|
||||||
const userObj = global.utils.getUserObjFromUsername(req.cookies.username);
|
const userObj = global.utils.getUserObjFromUsername(req.cookies.username);
|
||||||
|
|||||||
@@ -123,6 +123,9 @@ export async function getPoolResources (req, pool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const configs = await global.pve.getPoolResources(req.cookies, pool);
|
const configs = await global.pve.getPoolResources(req.cookies, pool);
|
||||||
|
if (configs === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
for (const vmid in configs) {
|
for (const vmid in configs) {
|
||||||
const config = configs[vmid];
|
const config = configs[vmid];
|
||||||
@@ -232,6 +235,11 @@ export async function approveResources (req, user, node, pool, request) {
|
|||||||
const poolResources = await getPoolResources(req, pool);
|
const poolResources = await getPoolResources(req, pool);
|
||||||
const reason = {};
|
const reason = {};
|
||||||
|
|
||||||
|
if (poolResources === null) {
|
||||||
|
reason["server"] = "error in retrieving pool resource state";
|
||||||
|
return {approved: false, reason};
|
||||||
|
}
|
||||||
|
|
||||||
for (const key in request) {
|
for (const key in request) {
|
||||||
// if requested resource is not specified in user resources, assume it's not allowed
|
// if requested resource is not specified in user resources, assume it's not allowed
|
||||||
if (!(key in poolResources)) {
|
if (!(key in poolResources)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user