Skip to content

Commit

Permalink
docker: lock docker controller requests pip module to 2.31.0
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed May 20, 2024
1 parent 4c9c702 commit 309eef6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
33 changes: 21 additions & 12 deletions scripts/saltbox_docker_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,19 +296,28 @@ def stop_containers_in_dependency_order(graph: DependencyGraph):
@asynccontextmanager
async def lifespan(app: FastAPI):
global app_ready
try:
# Initialization
client = docker.from_env()
docker_version = client.version()
logging.info(f"Using Docker version: {docker_version['Components'][0]['Version']}")

# Initialize DependencyGraph
global graph # Declare graph as global if it's used elsewhere outside this context
graph = DependencyGraph()
app_ready = True # Indicate that the app is now ready
retry_attempts = 10
retry_delay = 5

except Exception as e:
logging.error(f"An error occurred during application initialization: {e}")
for attempt in range(1, retry_attempts + 1):
try:
client = docker.from_env()
docker_version = client.version()
logging.info(f"Using Docker version: {docker_version['Components'][0]['Version']}")

# Initialize DependencyGraph
global graph # Declare graph as global if it's used elsewhere outside this context
graph = DependencyGraph()
app_ready = True # Indicate that the app is now ready
break # Exit the loop if successful

except Exception as e:
logging.error(f"Attempt {attempt} - An error occurred during Docker initialization: {e}")
if attempt < retry_attempts:
await asyncio.sleep(retry_delay)
else:
logging.critical("Failed to initialize Docker after multiple attempts. Exiting.")
raise SystemExit("Failed to initialize Docker. Exiting.")

yield
logging.info("Application shutdown complete")
Expand Down
7 changes: 4 additions & 3 deletions scripts/saltbox_docker_controller_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
docker~=7.0.0
uvicorn~=0.25.0
fastapi~=0.108.0
docker==7.0.0
uvicorn==0.29.0
fastapi==0.111.0
requests==2.31.0

0 comments on commit 309eef6

Please sign in to comment.