Logging and docs improvements
This commit is contained in:
parent
8167fad5ec
commit
d1e23fe551
1 changed files with 8 additions and 5 deletions
|
|
@ -12,13 +12,14 @@ _logger = logging.getLogger(__name__)
|
||||||
class Controller:
|
class Controller:
|
||||||
"""The controller monitors and manages the deployments.
|
"""The controller monitors and manages the deployments.
|
||||||
|
|
||||||
It run several background tasks:
|
It runs several background tasks:
|
||||||
|
|
||||||
- The 'watcher' listens to kubernetes events on deployements and maintains an
|
- The 'watcher' listens to kubernetes events on deployements and maintains an
|
||||||
in-memory database of existing deployments and their state. It wakes up the
|
in-memory database of existing deployments and their state. It wakes up the
|
||||||
starter and the reaper when necessary.
|
starter and the reaper when necessary.
|
||||||
- The 'starter' starts deployment that have been flagged to start, while making sure
|
- The 'starter' starts deployments that have been flagged to start, while making
|
||||||
that the maximum number of deployment starting concurrently does not exceed the
|
sure that the maximum number of deployment starting concurrently does not exceed
|
||||||
limit.
|
the limit.
|
||||||
- The 'stopper' stops old running deployments.
|
- The 'stopper' stops old running deployments.
|
||||||
- The 'undeployer' undeploys old stopped deployments.
|
- The 'undeployer' undeploys old stopped deployments.
|
||||||
"""
|
"""
|
||||||
|
|
@ -136,12 +137,14 @@ class Controller:
|
||||||
|
|
||||||
async def walking_dead(func):
|
async def walking_dead(func):
|
||||||
while True:
|
while True:
|
||||||
|
_logger.info(f"(Re)starting {func.__name__}")
|
||||||
try:
|
try:
|
||||||
await func()
|
await func()
|
||||||
except Exception:
|
except Exception:
|
||||||
delay = 5
|
delay = 5
|
||||||
_logger.exception(
|
_logger.exception(
|
||||||
f"Unhandled exception in {func}, restarting in {delay} sec."
|
f"Unhandled exception in {func.__name__}, "
|
||||||
|
f"restarting in {delay} sec."
|
||||||
)
|
)
|
||||||
await asyncio.sleep(delay)
|
await asyncio.sleep(delay)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue