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)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -337,8 +337,6 @@ router.post("/:disk/create", async (req, res) => {
|
||||
iso: req.body.iso
|
||||
};
|
||||
|
||||
console.log(req.cookies)
|
||||
|
||||
// attempt to parse user from username
|
||||
const userObj = global.utils.getUserObjFromUsername(req.cookies.username);
|
||||
if (userObj == null) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user