chore: Release lock on if already locked in IngressController and SwarmController

This commit is contained in:
Théophile Diot 2024-06-05 08:36:35 +01:00
parent f76cea979c
commit 2a24afb0bb
No known key found for this signature in database
GPG key ID: FA995104A0BA376A
2 changed files with 11 additions and 7 deletions

View file

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

View file

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