[PR #2] [CLOSED] Fixes a KeyError when the cluster contains pools #4

Closed
opened 2026-02-26 17:45:58 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/cvk98/Proxmox-host-maintenance-mode/pull/2
Author: @Cylindric
Created: 5/18/2022
Status: Closed

Base: mainHead: main


📝 Commits (2)

  • 6932c2c Add some supporting files
  • 6731ea5 Fix error when cluster contains pools

📊 Changes

3 files changed (+13 additions, -0 deletions)

View changed files

.gitignore (+3 -0)
📝 maintenance-mode.py (+2 -0)
requirements.txt (+8 -0)

📄 Description

When a cluster has one or more pools configured, they are returned in the /api2/json/cluster/resources endpoint along with the list of VMs. This causes a KeyError, as the pool objects do not have a status field.
This fix checks for and ignores pools.
I also added a requirements.txt.

For example:

{
  "data": [
    {
      "type": "pool",
      "cpu": 0.0488634206736965,
      "pool": "critical",
      "maxmem": 41875931136,
      "mem": 30204659946,
      "id": "/pool/critical",
      "maxcpu": 16,
      "uptime": 637030
    },
    {
      "node": "prox03",
      "id": "qemu/100",
      "hastate": "started",
      "uptime": 551319,
      "maxdisk": 21474836480,
      "name": "kube01",
      "vmid": 100,
      "type": "qemu",
      "diskwrite": 58090037248,
      "netin": 6295465475,
      "netout": 5716984801,
      "diskread": 481133056,
      "maxcpu": 2,
      "disk": 0,
      "pool": "critical",
      "cpu": 0.0828981259730304,
      "maxmem": 4294967296,
      "mem": 3877625856,
      "template": 0,
      "status": "running"
    }
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cvk98/Proxmox-host-maintenance-mode/pull/2 **Author:** [@Cylindric](https://github.com/Cylindric) **Created:** 5/18/2022 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`6932c2c`](https://github.com/cvk98/Proxmox-host-maintenance-mode/commit/6932c2c28bc6b4690034c97f06d8ea5fab37405e) Add some supporting files - [`6731ea5`](https://github.com/cvk98/Proxmox-host-maintenance-mode/commit/6731ea5a182ce230dbb431585cecec5ce621b0ee) Fix error when cluster contains pools ### 📊 Changes **3 files changed** (+13 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `.gitignore` (+3 -0) 📝 `maintenance-mode.py` (+2 -0) ➕ `requirements.txt` (+8 -0) </details> ### 📄 Description When a cluster has one or more pools configured, they are returned in the `/api2/json/cluster/resources` endpoint along with the list of VMs. This causes a `KeyError`, as the `pool` objects do not have a `status` field. This fix checks for and ignores pools. I also added a `requirements.txt`. For example: ```json { "data": [ { "type": "pool", "cpu": 0.0488634206736965, "pool": "critical", "maxmem": 41875931136, "mem": 30204659946, "id": "/pool/critical", "maxcpu": 16, "uptime": 637030 }, { "node": "prox03", "id": "qemu/100", "hastate": "started", "uptime": 551319, "maxdisk": 21474836480, "name": "kube01", "vmid": 100, "type": "qemu", "diskwrite": 58090037248, "netin": 6295465475, "netout": 5716984801, "diskread": 481133056, "maxcpu": 2, "disk": 0, "pool": "critical", "cpu": 0.0828981259730304, "maxmem": 4294967296, "mem": 3877625856, "template": 0, "status": "running" } } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 17:45:58 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxmox-host-maintenance-mode#4
No description provided.