From f36d96c72aa414f13806dd6f09ad5166c426785e Mon Sep 17 00:00:00 2001 From: Florian Paul Azim Hoberg Date: Thu, 17 Jul 2025 11:41:00 +0200 Subject: [PATCH] fix: Fix balancing evaluation of guest types (e.g., VM or CT). Fixes: #268 --- .../1.1.6/268_fix_balancing_type_eval.yml | 2 ++ .changelogs/1.1.6/release_meta.yml | 1 + proxlb/models/balancing.py | 16 ++++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .changelogs/1.1.6/268_fix_balancing_type_eval.yml create mode 100644 .changelogs/1.1.6/release_meta.yml diff --git a/.changelogs/1.1.6/268_fix_balancing_type_eval.yml b/.changelogs/1.1.6/268_fix_balancing_type_eval.yml new file mode 100644 index 0000000..1c9546a --- /dev/null +++ b/.changelogs/1.1.6/268_fix_balancing_type_eval.yml @@ -0,0 +1,2 @@ +fixed: + - Fix balancing evaluation of guest types (e.g., VM or CT) (@gyptazy). [#268] diff --git a/.changelogs/1.1.6/release_meta.yml b/.changelogs/1.1.6/release_meta.yml new file mode 100644 index 0000000..c19765d --- /dev/null +++ b/.changelogs/1.1.6/release_meta.yml @@ -0,0 +1 @@ +date: TBD diff --git a/proxlb/models/balancing.py b/proxlb/models/balancing.py index d6d45fa..76d23ae 100644 --- a/proxlb/models/balancing.py +++ b/proxlb/models/balancing.py @@ -90,11 +90,23 @@ class Balancing: # VM Balancing if guest_meta["type"] == "vm": - job_id = self.exec_rebalancing_vm(proxmox_api, proxlb_data, guest_name) + if 'vm' in proxlb_data["meta"]["balancing"].get("balance_types", []): + logger.debug("Balancing: Balancing for guest {guest_name} of type VM started.") + job_id = self.exec_rebalancing_vm(proxmox_api, proxlb_data, guest_name) + else: + logger.debug( + f"Balancing: Balancing for guest {guest_name} will not be performed. " + "Guest is of type VM which is not included in allowed balancing types.") # CT Balancing elif guest_meta["type"] == "ct": - job_id = self.exec_rebalancing_ct(proxmox_api, proxlb_data, guest_name) + if 'ct' in proxlb_data["meta"]["balancing"].get("balance_types", []): + logger.debug("Balancing: Balancing for guest {guest_name} of type CT started.") + job_id = self.exec_rebalancing_ct(proxmox_api, proxlb_data, guest_name) + else: + logger.debug( + f"Balancing: Balancing for guest {guest_name} will not be performed. " + "Guest is of type CT which is not included in allowed balancing types.") # Just in case we get a new type of guest in the future else: