gyptazy / ProxLB

ProxLB - (Re)Balance VM Workloads Across Nodes in Proxmox Clusters. A Load Balancer for Proxmox - and more!
https://proxlb.de
GNU General Public License v3.0
201 stars 9 forks source link

`Bug`: Error when rebalancing - Improve error handling #64

Closed JonahMMay closed 2 months ago

JonahMMay commented 2 months ago

I get the following error when ProxLB attempts to rebalance VMs on the latest merges to main:


  File "/home/administrator/ProxLB/proxlb", line 1392, in <module>
    main()
  File "/home/administrator/ProxLB/proxlb", line 1372, in main
    node_statistics, vm_statistics = balancing_vm_calculations(proxlb_config['vm_balancing_method'], proxlb_config['vm_balancing_mode'], proxlb_config['vm_balancing_mode_option'], node_statistics, vm_statistics, proxlb_config['vm_balanciness'], app_args, rebalance=False, processed_vms=[])
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/administrator/ProxLB/proxlb", line 737, in balancing_vm_calculations
    resources_node_most_free               = __get_most_free_resources_node(balancing_method, balancing_mode, balancing_mode_option, node_statistics)
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/administrator/ProxLB/proxlb", line 872, in __get_most_free_resources_node
    logging.info(f'{info_prefix} {node}')
                                  ^^^^
UnboundLocalError: cannot access local variable 'node' where it is not associated with a value```
JonahMMay commented 2 months ago

Looks like I said "byte" instead of "bytes" on the mode.

gyptazy commented 2 months ago

Hey @JonahMMay,

thanks for reporting this. Even when this was simply a typo, there should be a better error handling in place. I should add such validations into the pre_validation function to provide a better error message instead of this stack trace. Therefore, I'm reopening this issue.

Cheers, gyptazy