Skip to content

Commit

Permalink
fix: cache connection error to analysis nginx
Browse files Browse the repository at this point in the history
Co-authored-by: Nightknight3000 <[email protected]>
  • Loading branch information
antidodo and Nightknight3000 committed Nov 15, 2024
1 parent 6428314 commit 41076c0
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/status/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,25 +245,28 @@ def _get_internal_status(deployments: list[Analysis]) \


async def _get_internal_deployment_status(deployment_name: str) -> Optional[Literal['finished', 'ongoing', 'failed']]:
print(f"url : http://nginx-{deployment_name}:80")
response = await (AsyncClient(base_url=f'http://nginx-{deployment_name}:80')
.get('/analysis/healthz', headers=[('Connection', 'close')]))
print(f"response nginx-{deployment_name}/analysis/healthz: {response}")
try:
response.raise_for_status()
except httpx.HTTPStatusError as e:
print(f"Error getting internal deployment status: {e}")
response = await (AsyncClient(base_url=f'http://nginx-{deployment_name}:80')
.get('/analysis/healthz', headers=[('Connection', 'close')]))
print(f"response nginx-{deployment_name}/analysis/healthz: {response}")
try:
response.raise_for_status()
except httpx.HTTPStatusError as e:
print(f"Error getting internal deployment status: {e}")
return None
try:
print(f"analyse status: {response.json()}")
except json.decoder.JSONDecodeError:
print("No JSON in response")
analysis_health_status = response.json()['status']
if analysis_health_status == 'finished':
health_status = 'finished'
elif analysis_health_status == 'ongoing':
health_status = 'ongoing'
else:
health_status = 'failed'
return health_status

except httpx.ConnectError as e:
print(f"Connection to http://nginx-{deployment_name}:80 yielded an error: {e}")
return None
try:
print(f"analyse status: {response.json()}")
except json.decoder.JSONDecodeError:
print("No JSON in response")
analysis_health_status = response.json()['status']
if analysis_health_status == 'finished':
health_status = 'finished'
elif analysis_health_status == 'ongoing':
health_status = 'ongoing'
else:
health_status = 'failed'

return health_status

0 comments on commit 41076c0

Please sign in to comment.