autoconf - wait for scheduler to apply configuration before updating our own values so we can speedup the autoconf process

This commit is contained in:
florian 2024-05-03 16:25:29 +02:00
parent 24ec019141
commit ccaef7e90a
No known key found for this signature in database
GPG key ID: 93EE47CC3D061500
4 changed files with 20 additions and 0 deletions

View file

@ -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

View file

@ -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()

View file

@ -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()

View file

@ -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()