Skip to content

Commit f242be6

Browse files
committed
Fix: Orchestrator failed with assert result["result"] == HTTPOk.status_code
Problem: The diagnostic VM returned HTTP 200 with {"result": False} when it could not connect to the internet. Since this is an OK return code, `raise_for_status` did not raise an error and an assertion error was raised. Solution: Test that the returned status code also corresponds to HTTP OK.
1 parent b63d248 commit f242be6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/aleph/vm/orchestrator/status.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,15 @@ async def check_internet(session: ClientSession, vm_id: ItemHash) -> bool:
119119
"""Check that the VM has internet connectivity. This requires DNS, IP, HTTP and TLS to work."""
120120
try:
121121
result: dict = await get_json_from_vm(session, vm_id, "/internet")
122-
assert result["result"] == HTTPOk.status_code
122+
123+
# The HTTP Header "Server" must always be present in the result.
123124
assert "Server" in result["headers"]
125+
126+
# The diagnostic VM returns HTTP 200 with {"result": False} when cannot connect to the internet.
127+
# else it forwards the return code if its own test endpoint.
128+
if result.get("result") != HTTPOk.status_code:
129+
return False
130+
124131
return True
125132
except ClientResponseError:
126133
return False

0 commit comments

Comments
 (0)