Skip to content

Commit

Permalink
bootstrap: bootstrap: Log problems when using docker client
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Jun 23, 2024
1 parent 54fe1d6 commit f6fa320
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions bootstrap/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ def pull(self, component_name: str) -> None:

# if there is no curses support, like in the testing environment, just dump everything
if not curses_ui:
self.client.images.pull(f"{image_name}:{tag}")
try:
self.client.images.pull(f"{image_name}:{tag}")
except Exception as exception:
logger.warning(f"Failed to pull image ({image_name}:{tag}): {exception}")
return

# if there is ncurses support, proceed with it
Expand Down Expand Up @@ -154,8 +157,12 @@ def pull(self, component_name: str) -> None:

def image_is_available_locally(self, image_name: str, tag: str) -> bool:
"""Checks if the image is already available locally"""
images = self.client.images.list(image_name)
return any(f"{image_name}:{tag}" in image.tags for image in images)
try:
images = self.client.images.list(image_name)
return any(f"{image_name}:{tag}" in image.tags for image in images)
except Exception as exception:
logger.warning(f"Failed to list image ({image_name}): {exception}")
return false

def start(self, component_name: str) -> bool:
"""Loads settings and starts the containers. Loads default settings if no settings are found
Expand Down Expand Up @@ -218,7 +225,11 @@ def is_running(self, component: str) -> bool:
Returns:
bool: True if the chosen container is running
"""
return any(container.name.endswith(component) for container in self.client.containers.list())
try:
return any(container.name.endswith(component) for container in self.client.containers.list())
except Exception as exception:
logger.warning(f"Could not list containers: {exception}")
return False

def is_version_chooser_online(self) -> bool:
"""Check if the version chooser service is online.
Expand Down

0 comments on commit f6fa320

Please sign in to comment.