Просмотр исходного кода

feat: add coordinate service configurations, HAR files, and orchestration scripts

hujiarui 1 месяц назад
Родитель
Сommit
75e3befce6
3 измененных файлов с 30 добавлено и 9 удалено
  1. 10 3
      booker.py
  2. 10 3
      sentinel.py
  3. 10 3
      standalone.py

+ 10 - 3
booker.py

@@ -323,13 +323,20 @@ class BaseBookerGCO:
             )
 
     def _is_within_active_hours(self) -> bool:
-        """Checks if current time is within allowed operating hours."""
+        """Checks if current time is within allowed operating hours (UTC)."""
         start_str = self.m_cfg.active_time_start
         end_str = self.m_cfg.active_time_end
-        current_bj_time = datetime.utcnow().time()
+        if (start_str == "00:00" and end_str == "23:59") or not start_str or not end_str:
+            return True
+
+        current_utc_time = datetime.now(timezone.utc).time()
         start_time = datetime.strptime(start_str, "%H:%M").time()
         end_time = datetime.strptime(end_str, "%H:%M").time()
-        return start_time <= current_bj_time <= end_time
+
+        if start_time <= end_time:
+            return start_time <= current_utc_time <= end_time
+        else:
+            return current_utc_time >= start_time or current_utc_time <= end_time
 
     def _maintain_loop(self):
         self._log("Maintain loop started.")

+ 10 - 3
sentinel.py

@@ -279,14 +279,21 @@ class SentinelGCO:
 
     def _is_within_active_hours(self) -> bool:
         """
-        Checks if current time is within allowed operating hours.
+        Checks if current time is within allowed operating hours (UTC).
         """
         start_str = self.m_cfg.active_time_start
         end_str = self.m_cfg.active_time_end
-        current_bj_time = datetime.utcnow().time()
+        if (start_str == "00:00" and end_str == "23:59") or not start_str or not end_str:
+            return True
+
+        current_utc_time = datetime.now(timezone.utc).time()
         start_time = datetime.strptime(start_str, "%H:%M").time()
         end_time = datetime.strptime(end_str, "%H:%M").time()
-        return start_time <= current_bj_time <= end_time
+
+        if start_time <= end_time:
+            return start_time <= current_utc_time <= end_time
+        else:
+            return current_utc_time >= start_time or current_utc_time <= end_time
 
     def _monitor_loop(self):
         self._log("Monitor loop started.")

+ 10 - 3
standalone.py

@@ -74,13 +74,20 @@ class StandaloneGCO:
         return 30.0
 
     def _is_within_active_hours(self) -> bool:
-        """Determine if current time is within active operating window for instances and queries."""
+        """Determine if current time is within active operating window for instances and queries (UTC)."""
         start_str = self.m_cfg.active_time_start
         end_str = self.m_cfg.active_time_end
-        current_bj_time = datetime.utcnow().time()
+        if (start_str == "00:00" and end_str == "23:59") or not start_str or not end_str:
+            return True
+
+        current_utc_time = datetime.now(timezone.utc).time()
         start_time = datetime.strptime(start_str, "%H:%M").time()
         end_time = datetime.strptime(end_str, "%H:%M").time()
-        return start_time <= current_bj_time <= end_time
+
+        if start_time <= end_time:
+            return start_time <= current_utc_time <= end_time
+        else:
+            return current_utc_time >= start_time or current_utc_time <= end_time
 
     def update_config(self, new_cfg: BookerStandaloneConfig):
         """Dynamically update group configuration."""