[GH-ISSUE #35] Trivial patch to disable looping (for crond) #21

Open
opened 2026-02-26 17:46:08 +03:00 by kerem · 0 comments
Owner

Originally created by @kjj2 on GitHub (May 21, 2024).
Original GitHub issue: https://github.com/cvk98/Proxmox-load-balancer/issues/35

This patch adds loop to the parameters section of the config file. If this is not set, or set to Off, the script will exit at the end of a balancing run. This is useful if you want to avoid having the load balancer run while (for example) backups are running.

--- plb.py      2024-05-21 04:56:39.802275066 -0500
+++ plb-loop_option.py   2024-05-21 04:52:25.979306790 -0500
@@ -32,6 +32,7 @@
 LXC_MIGRATION = cfg["parameters"]["lxc_migration"]
 MIGRATION_TIMEOUT = cfg["parameters"]["migration_timeout"]
 ONLY_ON_MASTER = cfg["parameters"].get("only_on_master", False)
+LOOP = cfg["parameters"].get("loop", False)

 """Exclusions"""
 excluded_vms = []
@@ -485,9 +574,13 @@
             sleep(60)
             pass  # TODO Aggressive algorithm
     else:
-        logger.info('The cluster is balanced. Waiting 300 seconds.')
-        iteration += 1
-        sleep(300)
+        if LOOP:
+            logger.info('The cluster is balanced. Waiting 300 seconds.')
+            iteration += 1
+            sleep(300)
+        else:
+            logger.info('Looping not enabled.  exiting.')
+            sys.exit(0)


 while True:

Originally created by @kjj2 on GitHub (May 21, 2024). Original GitHub issue: https://github.com/cvk98/Proxmox-load-balancer/issues/35 This patch adds loop to the parameters section of the config file. If this is not set, or set to Off, the script will exit at the end of a balancing run. This is useful if you want to avoid having the load balancer run while (for example) backups are running. ``` --- plb.py 2024-05-21 04:56:39.802275066 -0500 +++ plb-loop_option.py 2024-05-21 04:52:25.979306790 -0500 @@ -32,6 +32,7 @@ LXC_MIGRATION = cfg["parameters"]["lxc_migration"] MIGRATION_TIMEOUT = cfg["parameters"]["migration_timeout"] ONLY_ON_MASTER = cfg["parameters"].get("only_on_master", False) +LOOP = cfg["parameters"].get("loop", False) """Exclusions""" excluded_vms = [] @@ -485,9 +574,13 @@ sleep(60) pass # TODO Aggressive algorithm else: - logger.info('The cluster is balanced. Waiting 300 seconds.') - iteration += 1 - sleep(300) + if LOOP: + logger.info('The cluster is balanced. Waiting 300 seconds.') + iteration += 1 + sleep(300) + else: + logger.info('Looping not enabled. exiting.') + sys.exit(0) while True: ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxmox-load-balancer#21
No description provided.