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

feature: Add storage balancing function. #55

Closed gyptazy closed 2 months ago

gyptazy commented 2 months ago

Features

General

This PR adds the feature to also allow storage balancing and supports VMs and CTs. It also supports multiple disks assigned to VMs and CTs. In the first iteration it can only balance by disk_space. I'm currently still evaluating to implement also an additional balancing method by disk_io.

Tests

Storage Balancing

<6> ProxLB: Info: [storage-balanciness-validation]: Getting most free storage volume by disk size.
<6> ProxLB: Info: [storage-balanciness-validation]: Validating storage: net-nfs01 for balanciness for usage with: disk_space.
<6> ProxLB: Info: [storage-balanciness-validation]: Storage: net-nfs01 with values: {'name': 'net-nfs01', 'total': 314915684352, 'used': 151707975680, 'used_percent': 48.174156835715735, 'used_percent_last_run': 48.174156835715735, 'free': 163207708672, 'free_percent': 51.825843164284265, 'used_fraction': 0.481741568357157, 'type': 'nfs', 'content': 'rootdir,images', 'usage_type': 'all', 'used_percent_match': False}
<6> ProxLB: Info: [storage-balanciness-validation]: Validating storage: net-nfs02 for balanciness for usage with: disk_space.
<6> ProxLB: Info: [storage-balanciness-validation]: Storage: net-nfs02 with values: {'name': 'net-nfs02', 'total': 209231282176, 'used': 35651584000, 'used_percent': 17.039318226808362, 'used_percent_last_run': 17.039318226808362, 'free': 173579698176, 'free_percent': 82.96068177319164, 'used_fraction': 0.170393182268084, 'type': 'nfs', 'content': 'images', 'usage_type': 'vm', 'used_percent_match': False}
<6> ProxLB: Info: [storage-balanciness-validation]: Rebalancing for type "used" of storage is needed. Highest usage: 48% | Lowest usage: 17%.
<6> ProxLB: Info: [get-most-used-disks-resources-vm]: Got most used VM: test02 with storage device: virtio1.
<6> ProxLB: Info: [get-most-free-storage]: Starting to evaluate the most free storage volume.
<6> ProxLB: Info: [get-most-free-storage]: Getting most free storage volume by disk space.
<6> ProxLB: Info: [rebalancing-storage-resource-statistics-update]: Validating VM test02 for potential storage rebalancing.
<6> ProxLB: Info: [rebalancing-storage-resource-statistics-update]: Setting VM test02 from net-nfs01 to net-nfs02 storage.
<6> ProxLB: Info: [rebalancing-storage-resource-statistics-update]: Adding free space of 34G to old storage with 151.9990234375G. [free: 185G | 63.418540457567914%]
<6> ProxLB: Info: [rebalancing-storage-resource-statistics-update]: Adding used space of 34G to new storage with 161.65869140625G. [free: 127G | 65.51241990893988%]
<6> ProxLB: Info: [rebalancing-storage-resource-statistics-update]: Updated VM and storage statistics.
<6> ProxLB: Info: [storage-balanciness-validation]: Getting most free storage volume by disk size..
<6> ProxLB: Info: [storage-balanciness-validation]: Validating storage: net-nfs01 for balanciness for usage with: disk_space.
<6> ProxLB: Info: [storage-balanciness-validation]: Storage: net-nfs01 with values: {'name': 'net-nfs01', 'total': 314915684352, 'used': 115200753664, 'used_percent': 36.581459542432086, 'used_percent_last_run': 36.581459542432086, 'free': 199714930688, 'free_percent': 63.418540457567914, 'used_fraction': 0.481741568357157, 'type': 'nfs', 'content': 'rootdir,images', 'usage_type': 'all', 'used_percent_match': False}
<6> ProxLB: Info: [storage-balanciness-validation]: Validating storage: net-nfs02 for balanciness for usage with: disk_space.
<6> ProxLB: Info: [storage-balanciness-validation]: Storage: net-nfs02 with values: {'name': 'net-nfs02', 'total': 209231282176, 'used': 72158806016, 'used_percent': 34.487580091060124, 'used_percent_last_run': 34.487580091060124, 'free': 137072476160, 'free_percent': 65.51241990893988, 'used_fraction': 0.170393182268084, 'type': 'nfs', 'content': 'images', 'usage_type': 'vm', 'used_percent_match': False}
<6> ProxLB: Info: [storage-balanciness-validation]: Rebalancing for type "used" of storage is not needed. Highest usage: 36% | Lowest usage: 34%.
<6> ProxLB: Info: [storage-rebalancing-calculator]: Balancing calculations done.
<6> ProxLB: Info: [storage-rebalancing-calculator]: Balancing calculations done.

Allow Multiple API Hosts

<6> ProxLB: Info: [logger]: Logger verbosity got updated to: INFO.
<4> ProxLB: Warning: [api-connection]: API connection does not verify SSL certificate.
<6> ProxLB: Info: [api-connect-get-host]: Multiple hosts for API connection are given. Testing hosts for further usage.
<6> ProxLB: Info: [api-connect-get-host]: Testing host 8.8.8.8 on port tcp/8006.
<6> ProxLB: Info: [api-connect-test-host]: Timeout for host 8.8.8.8 is set to 2 seconds.
<2> ProxLB: Error: [api-connect-test-host]: Host 8.8.8.8 is unreachable on port tcp/8006.
<6> ProxLB: Info: [api-connect-get-host]: Testing host 10.10.10.211 on port tcp/8006.
<6> ProxLB: Info: [api-connect-test-host]: Timeout for host 10.10.10.211 is set to 2 seconds.
<6> ProxLB: Info: [api-connect-test-host]: Host 10.10.10.211 is reachable on port tcp/8006.
<6> ProxLB: Info: [api-connection]: API connection succeeded to host: 10.10.10.211.

Misc

Status: WIP Fixes: #51 Fixes: #60