add retry

This commit is contained in:
Adil Hafeez 2025-01-08 14:47:32 -08:00
parent a48c9d654a
commit be2c0330d2
2 changed files with 15 additions and 5 deletions

View file

@ -4,6 +4,7 @@ import time
import sys
import glob
import docker
from docker.errors import DockerException
from cli.utils import getLogger, update_docker_host_env
from cli.consts import (
ARCHGW_DOCKER_IMAGE,
@ -110,8 +111,12 @@ def start_arch(arch_config_file, env, log_timeout=120, foreground=False):
log.info("Starting arch gateway")
try:
update_docker_host_env()
client = docker.from_env()
try:
client = docker.from_env()
except DockerException as e:
# try setting up the docker host environment variable and retry
update_docker_host_env()
client = docker.from_env()
try:
container = client.containers.get("archgw")

View file

@ -2,6 +2,7 @@ import os
import yaml
import logging
import docker
from docker.errors import DockerException
from cli.consts import ARCHGW_DOCKER_IMAGE, ARCHGW_DOCKER_NAME
@ -39,9 +40,13 @@ def update_docker_host_env():
def validate_schema(arch_config_file: str) -> None:
try:
update_docker_host_env()
client = docker.from_env()
# Run the container with detach=True to avoid blocking main process
try:
client = docker.from_env()
except DockerException as e:
# try setting up the docker host environment variable and retry
update_docker_host_env()
client = docker.from_env()
container = client.containers.run(
image=ARCHGW_DOCKER_IMAGE,
volumes={