diff --git a/src/autoconf/IngressController.py b/src/autoconf/IngressController.py index 498e784cb..865f27996 100644 --- a/src/autoconf/IngressController.py +++ b/src/autoconf/IngressController.py @@ -258,8 +258,9 @@ class IngressController(Controller): self._configs = self.get_configs() if not to_apply and not self.update_needed(self._instances, self._services, configs=self._configs): - self.__internal_lock.release() - locked = False + if locked: + self.__internal_lock.release() + locked = False applied = True continue @@ -281,8 +282,9 @@ class IngressController(Controller): self._logger.error(f"Exception while deploying new configuration :\n{format_exc()}") applied = True - self.__internal_lock.release() - locked = False + if locked: + self.__internal_lock.release() + locked = False except ApiException as e: if e.status != 410: self._logger.error( diff --git a/src/autoconf/SwarmController.py b/src/autoconf/SwarmController.py index 4bd443281..6b35a4f00 100644 --- a/src/autoconf/SwarmController.py +++ b/src/autoconf/SwarmController.py @@ -142,8 +142,9 @@ class SwarmController(Controller): self._configs = self.get_configs() if not to_apply and not self.update_needed(self._instances, self._services, configs=self._configs): - self.__internal_lock.release() - locked = False + if locked: + self.__internal_lock.release() + locked = False applied = True continue @@ -163,7 +164,8 @@ class SwarmController(Controller): applied = True except BaseException: self._logger.error(f"Exception while processing Swarm event ({event_type}) :\n{format_exc()}") - finally: + + if locked: self.__internal_lock.release() locked = False except: