From d53a6f695ff01bcfccc2807d6476774ac8828179 Mon Sep 17 00:00:00 2001 From: Florian Paul Azim Hoberg Date: Fri, 13 Sep 2024 08:37:32 +0200 Subject: [PATCH] fix: Run storage balancing only on support shared storages and when really needed. Fixes: #79 --- .changelogs/1.0.4/79_storage_balancing_whitelist.yml | 3 +++ .changelogs/1.0.4/release_meta.yml | 1 + proxlb | 10 +++++++--- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .changelogs/1.0.4/79_storage_balancing_whitelist.yml create mode 100644 .changelogs/1.0.4/release_meta.yml diff --git a/.changelogs/1.0.4/79_storage_balancing_whitelist.yml b/.changelogs/1.0.4/79_storage_balancing_whitelist.yml new file mode 100644 index 0000000..dd44590 --- /dev/null +++ b/.changelogs/1.0.4/79_storage_balancing_whitelist.yml @@ -0,0 +1,3 @@ +changed: + - Run storage balancing only on supported shared storages. [#79] + - Run storage balancing only when needed to save time. [#79] diff --git a/.changelogs/1.0.4/release_meta.yml b/.changelogs/1.0.4/release_meta.yml new file mode 100644 index 0000000..c19765d --- /dev/null +++ b/.changelogs/1.0.4/release_meta.yml @@ -0,0 +1 @@ +date: TBD diff --git a/proxlb b/proxlb index a963a73..1ef0e29 100755 --- a/proxlb +++ b/proxlb @@ -42,7 +42,7 @@ import urllib3 # Constants __appname__ = "ProxLB" -__version__ = "1.0.3b" +__version__ = "1.0.4b" __config_version__ = 3 __author__ = "Florian Paul Azim Hoberg @gyptazy" __errors__ = False @@ -680,6 +680,7 @@ def update_node_statistics(node_statistics, vm_statistics): def get_storage_statistics(api_object): """ Get statistics of all storage in the cluster. """ info_prefix = 'Info: [storage-statistics]:' + storage_whitelist = ['nfs'] storage_statistics = {} for node in api_object.nodes.get(): @@ -688,7 +689,7 @@ def get_storage_statistics(api_object): # Only add enabled and active storage repositories that might be suitable for further # storage balancing. - if storage['enabled'] and storage['active'] and storage['shared']: + if storage['enabled'] and storage['active'] and storage['shared'] and storage['type'] in storage_whitelist: storage_statistics[storage['storage']] = {} storage_statistics[storage['storage']]['name'] = storage['storage'] storage_statistics[storage['storage']]['total'] = storage['total'] @@ -1477,7 +1478,10 @@ def main(): node_statistics = get_node_statistics(api_object, proxlb_config['vm_ignore_nodes']) vm_statistics = get_vm_statistics(api_object, proxlb_config['vm_ignore_vms'], proxlb_config['vm_balancing_type']) node_statistics = update_node_statistics(node_statistics, vm_statistics) - storage_statistics = get_storage_statistics(api_object) + # Obtaining metrics for the storage may take longer times and is not needed for VM/CT balancing. + # We can save time by skipping this when not really needed. + if proxlb_config['storage_balancing_enable']: + storage_statistics = get_storage_statistics(api_object) # Execute VM/CT balancing sub-routines. if proxlb_config['vm_balancing_enable'] or app_args.best_node: