`Bug`: Guest relocation fails in PSI mode due to KeyError on non-existent metric key
bugready-for-release
When running ProxLB in PSI mode, the guest relocation fails with a KeyError. The problem occurs because the code dynamically constructs a key using the method and mode values (n[f"{method}_{mode}_percent"]). In PSI mode, this results in a non-existent key (memory_psi_percent) in the nodes’ data structure, causing the crash. This prevents ProxLB from completing the load balancing and guest relocation process.
Weighting
Score: 8
This issue is high priority because it causes the load balancing process to fail entirely in PSI mode, which may affect production systems.
Log
```
Traceback (most recent call last):
File "/Users/bosettie/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1570, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bosettie/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bosettie/ProxLB/proxlb/main.py", line 118, in <module>
main()
~~~~^^
File "/Users/bosettie/ProxLB/proxlb/main.py", line 100, in main
Calculations.relocate_guests(proxlb_data)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/Users/bosettie/ProxLB/proxlb/models/calculations.py", line 425, in relocate_guests
highest_node = max(proxlb_data["nodes"].values(), key=lambda n: n[f"{method}_{mode}_percent"])
File "/Users/bosettie/ProxLB/proxlb/models/calculations.py", line 425, in <lambda>
highest_node = max(proxlb_data["nodes"].values(), key=lambda n: n[f"{method}_{mode}_percent"])
~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'memory_psi_percent'
```
https://github.com/gyptazy/ProxLB/blob/65b1bd5feef6b587119b284467e978cebe4351b5/proxlb/models/calculations.py#L425
Meta
Version: v1.1.11
Running as: Container
1 条评论