fix: Use method and mode specified in configuration to calculate lowest_usage_node

This commit is contained in:
glitchvern
2025-04-15 16:25:01 +00:00
parent 94552f9c9e
commit 34b1d72e40
2 changed files with 5 additions and 1 deletions

View File

@@ -0,0 +1,2 @@
fixed:
- Remove hard coded memory usage from lowest usage node and use method and mode specified in configuration instead (by @glitchvern) [#197]

View File

@@ -147,7 +147,9 @@ class Calculations:
# Do not include nodes that are marked in 'maintenance'
filtered_nodes = [node for node in proxlb_data["nodes"].values() if not node["maintenance"]]
lowest_usage_node = min(filtered_nodes, key=lambda x: x["memory_used_percent"])
method = proxlb_data["meta"]["balancing"].get("method", "memory")
mode = proxlb_data["meta"]["balancing"].get("mode", "used")
lowest_usage_node = min(filtered_nodes, key=lambda x: x[f"{method}_{mode}_percent"])
proxlb_data["meta"]["balancing"]["balance_reason"] = 'resources'
proxlb_data["meta"]["balancing"]["balance_next_node"] = lowest_usage_node["name"]