mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
autoconf - wait for scheduler to apply configuration before updating our own values so we can speedup the autoconf process
This commit is contained in:
parent
24ec019141
commit
ccaef7e90a
4 changed files with 20 additions and 0 deletions
|
|
@ -61,6 +61,23 @@ class Config(ConfigCaller):
|
|||
return True
|
||||
return False
|
||||
|
||||
def wait_applying(self):
|
||||
i = 0
|
||||
while i < 10:
|
||||
curr_changes = self._db.check_changes()
|
||||
if isinstance(curr_changes, str):
|
||||
self.__logger.error(f"An error occurred when checking for changes in the database : {curr_changes}")
|
||||
elif not any(curr_changes.values()):
|
||||
break
|
||||
else:
|
||||
self.__logger.warning(
|
||||
"Scheduler is already applying a configuration, retrying in 5 seconds ...",
|
||||
)
|
||||
i += 1
|
||||
sleep(5)
|
||||
if i >= 10:
|
||||
raise Exception("Too many retries while waiting for scheduler to apply configuration...")
|
||||
|
||||
def apply(self, instances, services, configs={}, first=False) -> bool:
|
||||
success = True
|
||||
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ class DockerController(Controller):
|
|||
try:
|
||||
if not self.__process_event(event):
|
||||
continue
|
||||
self.wait_applying()
|
||||
self._update_settings()
|
||||
self._instances = self.get_instances()
|
||||
self._services = self.get_services()
|
||||
|
|
|
|||
|
|
@ -278,6 +278,7 @@ class IngressController(Controller):
|
|||
self.__internal_lock.release()
|
||||
locked = False
|
||||
continue
|
||||
self.wait_applying()
|
||||
self._update_settings()
|
||||
self._instances = self.get_instances()
|
||||
self._services = self.get_services()
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ class SwarmController(Controller):
|
|||
locked = False
|
||||
continue
|
||||
try:
|
||||
self.wait_applying()
|
||||
self._update_settings()
|
||||
self._instances = self.get_instances()
|
||||
self._services = self.get_services()
|
||||
|
|
|
|||
Loading…
Reference in a new issue