Skip to content

Commit

Permalink
Improve deployment exit code handling (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin-Molinero authored Nov 15, 2024
1 parent 168b277 commit 1b9246e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lean/components/docker/docker_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,17 +179,23 @@ def run_image(self, image: DockerImage, **kwargs) -> bool:
from time import sleep
i = 0
self._logger.info(f'Verifying deployment \'{container.name}\' is stable...')
while i < 30:
while i < 35:
i += 1
container.reload()
if (container.status != "running" and container.attrs and "State" in container.attrs and "ExitCode"
in container.attrs["State"] and container.attrs["State"]["ExitCode"] != 0):
# container is failing
self._logger.debug(f'Deployment \'{container.name}\' last logs: {str(container.logs(tail=10).decode("utf-8"))}')
last_logs = str(container.logs(tail=10).decode("utf-8"))
exit_code = container.attrs["State"]["ExitCode"]
raise RuntimeError(f'Deployment \'{container.name}\' is failing, exit code {exit_code}.'
f' Please validate your subscription is valid, you can check your product'
f' subscriptions on our website.')
if exit_code == 15:
self._logger.debug(f'Deployment \'{container.name}\' last logs:\n{last_logs}')
raise RuntimeError(f'Deployment \'{container.name}\' is failing, exit code {exit_code}.'
f' Please validate your subscription is valid, you can check your product'
f' subscriptions on our website.')
else:
raise RuntimeError(f'Deployment \'{container.name}\' is failing, exit code {exit_code}.'
f' Please review deployment logs and associated documentation.'
f' Last logs:\n{last_logs}')
sleep(0.5)
self._logger.info(f'Deployment \'{container.name}\' is stable')
if detach:
Expand Down

0 comments on commit 1b9246e

Please sign in to comment.