Skip to content

Commit 9966fbb

Browse files
authored
Merge pull request #421 from gyptazy/fix/420-fix-psi-based-balancing-mode
fix(calculations): Fix PSI based balancing which resulted in a Python KeyError
2 parents 65b1bd5 + e6ae357 commit 9966fbb

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fixed:
2+
- Fix PSI based balancing which resulted in a Python KeyError (@gyptazy). [#420]

proxlb/models/calculations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,12 @@ def relocate_guests(proxlb_data: Dict[str, Any]):
418418
break
419419

420420
for guest_name in proxlb_data["groups"]["affinity"][group_name]["guests"]:
421+
421422
# Stop moving guests if the source node is no longer the most loaded
422423
source_node = proxlb_data["guests"][guest_name]["node_current"]
423424
method = proxlb_data["meta"]["balancing"].get("method", "memory")
424425
mode = proxlb_data["meta"]["balancing"].get("mode", "used")
425-
highest_node = max(proxlb_data["nodes"].values(), key=lambda n: n[f"{method}_{mode}_percent"])
426+
highest_node = max(proxlb_data["nodes"].values(), key=lambda n: n[f"{method}_used_percent"])
426427

427428
if highest_node["name"] != source_node:
428429
logger.debug(f"Stopping relocation for guest {guest_name}: source node {source_node} is no longer the most loaded node.")

0 commit comments

Comments
 (0)