Skip to content

Commit

Permalink
bootstrap: bootstrap: Add message when it detects version chooser as …
Browse files Browse the repository at this point in the history
…online after offline

Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Jun 23, 2024
1 parent 467ef61 commit 200b451
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bootstrap/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Bootstrapper:
core_last_response_time = time.monotonic()

def __init__(self, client: docker.DockerClient, low_level_api: docker.APIClient = None) -> None:
self.version_chooser_is_online = False
self.client: docker.DockerClient = client
self.core_last_response_time = time.monotonic()
if low_level_api is None:
Expand Down Expand Up @@ -240,11 +241,15 @@ def is_version_chooser_online(self) -> bool:
try:
response = requests.get("http://localhost/version-chooser/v1.0/version/current", timeout=10)
if Bootstrapper.SETTINGS_NAME_CORE in response.json()["repository"]:
if not self.version_chooser_is_online:
self.version_chooser_is_online = True
logger.ingo("Version chooser is online")
return True
except Exception as e:
logger.warning(
f"Could not talk to version chooser for {time.monotonic() - self.core_last_response_time}: {e}"
)
self.version_chooser_is_online = False
return False

def remove(self, container: str) -> None:
Expand Down

0 comments on commit 200b451

Please sign in to comment.