From d2db7c9078b75e8fe480cbff92468c4ca2cb65d6 Mon Sep 17 00:00:00 2001 From: fabriziosalmi Date: Sat, 1 Feb 2025 11:41:31 +0100 Subject: [PATCH] off_peak bugfix --- lxc_autoscale/scaling_manager.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lxc_autoscale/scaling_manager.py b/lxc_autoscale/scaling_manager.py index b8ee939..be06dc8 100644 --- a/lxc_autoscale/scaling_manager.py +++ b/lxc_autoscale/scaling_manager.py @@ -464,5 +464,10 @@ def is_off_peak() -> bool: True if it is off-peak, otherwise False. """ current_hour = datetime.now().hour - logging.debug(f"Current hour: {current_hour}, Off-peak hours: {DEFAULTS['off_peak_start']} - {DEFAULTS['off_peak_end']}") - return DEFAULTS['off_peak_start'] <= current_hour or current_hour < DEFAULTS['off_peak_end'] \ No newline at end of file + start = DEFAULTS['off_peak_start'] + end = DEFAULTS['off_peak_end'] + logging.debug(f"Current hour: {current_hour}, Off-peak hours: {start} - {end}") + if start < end: + return start <= current_hour < end + else: + return current_hour >= start or current_hour < end \ No newline at end of file