diff --git a/.changelogs/1.1.1/163_fix_ignore_vm_tag.yml b/.changelogs/1.1.1/163_fix_ignore_vm_tag.yml new file mode 100644 index 0000000..c062a59 --- /dev/null +++ b/.changelogs/1.1.1/163_fix_ignore_vm_tag.yml @@ -0,0 +1,2 @@ +fixed: + - Fix tag evluation for VMs for being ignored for further balancing [#163] diff --git a/.changelogs/1.1.1/165_improve_logging_servity.yml b/.changelogs/1.1.1/165_improve_logging_servity.yml new file mode 100644 index 0000000..bda8f2c --- /dev/null +++ b/.changelogs/1.1.1/165_improve_logging_servity.yml @@ -0,0 +1,2 @@ +fixed: + - Improve logging verbosity of messages that had a wrong servity [#165] diff --git a/.changelogs/1.1.1/release_meta.yml b/.changelogs/1.1.1/release_meta.yml new file mode 100644 index 0000000..c19765d --- /dev/null +++ b/.changelogs/1.1.1/release_meta.yml @@ -0,0 +1 @@ +date: TBD diff --git a/proxlb/models/balancing.py b/proxlb/models/balancing.py index 7a8bbfa..3fb22a9 100644 --- a/proxlb/models/balancing.py +++ b/proxlb/models/balancing.py @@ -52,22 +52,30 @@ class Balancing: """ for guest_name, guest_meta in proxlb_data["guests"].items(): + # Check if the the guest's target is not the same as the current node if guest_meta["node_current"] != guest_meta["node_target"]: - guest_id = guest_meta["id"] - guest_node_current = guest_meta["node_current"] - guest_node_target = guest_meta["node_target"] + # Check if the guest is not ignored and perform the balancing + # operation based on the guest type + if not guest_meta["ignore"]: + guest_id = guest_meta["id"] + guest_node_current = guest_meta["node_current"] + guest_node_target = guest_meta["node_target"] - # VM Balancing - if guest_meta["type"] == "vm": - self.exec_rebalancing_vm(proxmox_api, proxlb_data, guest_name) + # VM Balancing + if guest_meta["type"] == "vm": + self.exec_rebalancing_vm(proxmox_api, proxlb_data, guest_name) - # CT Balancing - elif guest_meta["type"] == "ct": - self.exec_rebalancing_ct(proxmox_api, proxlb_data, guest_name) + # CT Balancing + elif guest_meta["type"] == "ct": + self.exec_rebalancing_ct(proxmox_api, proxlb_data, guest_name) - # Hopefully never reaching, but should be catched + # Just in case we get a new type of guest in the future + else: + logger.critical(f"Balancing: Got unexpected guest type: {guest_meta['type']}. Cannot proceed guest: {guest_meta['name']}.") else: - logger.critical(f"Balancing: Got unexpected guest type: {guest_meta['type']}. Cannot proceed guest: {guest_meta['name']}.") + logger.debug(f"Balancing: Guest {guest_name} is ignored and will not be rebalanced.") + else: + logger.debug(f"Balancing: Guest {guest_name} is already on the target node {guest_meta['node_target']} and will not be rebalanced.") def exec_rebalancing_vm(self, proxmox_api: any, proxlb_data: Dict[str, Any], guest_name: str) -> None: """ diff --git a/proxlb/models/calculations.py b/proxlb/models/calculations.py index 8b625ae..5c3a9f2 100644 --- a/proxlb/models/calculations.py +++ b/proxlb/models/calculations.py @@ -119,10 +119,8 @@ class Calculations: if method_value_highest - method_value_lowest > balanciness: proxlb_data["meta"]["balancing"]["balance"] = True logger.debug(f"Guest balancing is required. Highest value: {method_value_highest}, lowest value: {method_value_lowest} balanced by {method} and {mode}.") - logger.critical(f"Guest balancing is required. Highest value: {method_value_highest}, lowest value: {method_value_lowest} balanced by {method} and {mode}.") else: logger.debug(f"Guest balancing is ok. Highest value: {method_value_highest}, lowest value: {method_value_lowest} balanced by {method} and {mode}.") - logger.critical(f"Guest balancing is ok. Highest value: {method_value_highest}, lowest value: {method_value_lowest} balanced by {method} and {mode}.") else: logger.warning("No guests for balancing found.")