Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Orchestrator failed with assert result["result"] == HTTPOk.status_code #628

Merged
merged 1 commit into from
Jun 13, 2024

Conversation

hoh
Copy link
Member

@hoh hoh commented Jun 5, 2024

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.

Stacktrace:

Jun 05 10:39:20 testing-hetzner python3[1400146]: vm-5 1851967.687130 |V DEBUG | <<<
Jun 05 10:39:20 testing-hetzner python3[1400146]: vm-5
Jun 05 10:39:25 testing-hetzner python3[1400146]: vm-5 2024-06-05 10:39:25,688 | ERROR | Error handling request
Jun 05 10:39:25 testing-hetzner python3[1400146]: Traceback (most recent call last):
Jun 05 10:39:25 testing-hetzner python3[1400146]:   File "/opt/aleph-vm/aiohttp/web_protocol.py", line 452, in _handle_request
Jun 05 10:39:25 testing-hetzner python3[1400146]:     resp = await request_handler(request)
Jun 05 10:39:25 testing-hetzner python3[1400146]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 05 10:39:25 testing-hetzner python3[1400146]:   File "/opt/aleph-vm/sentry_sdk/integrations/aiohttp.py", line 139, in sentry_app_handle
Jun 05 10:39:25 testing-hetzner python3[1400146]:     reraise(*_capture_exception(hub))
Jun 05 10:39:25 testing-hetzner python3[1400146]:   File "/opt/aleph-vm/sentry_sdk/_compat.py", line 99, in reraise
Jun 05 10:39:25 testing-hetzner python3[1400146]:     raise value
Jun 05 10:39:25 testing-hetzner python3[1400146]:   File "/opt/aleph-vm/sentry_sdk/integrations/aiohttp.py", line 129, in sentry_app_handle
Jun 05 10:39:25 testing-hetzner python3[1400146]:     response = await old_handle(self, request)
Jun 05 10:39:25 testing-hetzner python3[1400146]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 05 10:39:25 testing-hetzner python3[1400146]:   File "/opt/aleph-vm/aiohttp/web_app.py", line 543, in _handle
Jun 05 10:39:25 testing-hetzner python3[1400146]:     resp = await handler(request)
Jun 05 10:39:25 testing-hetzner python3[1400146]:            ^^^^^^^^^^^^^^^^^^^^^^
Jun 05 10:39:25 testing-hetzner python3[1400146]:   File "/opt/aleph-vm/aiohttp/web_middlewares.py", line 114, in impl
Jun 05 10:39:25 testing-hetzner python3[1400146]:     return await handler(request)
Jun 05 10:39:25 testing-hetzner python3[1400146]:            ^^^^^^^^^^^^^^^^^^^^^^
Jun 05 10:39:25 testing-hetzner python3[1400146]:   File "/opt/aleph-vm/aleph/vm/orchestrator/supervisor.py", line 65, in server_version_middleware
Jun 05 10:39:25 testing-hetzner python3[1400146]:     resp: web.StreamResponse = await handler(request)
Jun 05 10:39:25 testing-hetzner python3[1400146]:                                ^^^^^^^^^^^^^^^^^^^^^^
Jun 05 10:39:25 testing-hetzner python3[1400146]:   File "/opt/aleph-vm/aleph/vm/orchestrator/views/__init__.py", line 215, in status_check_fastapi
Jun 05 10:39:25 testing-hetzner python3[1400146]:     "internet": await status.check_internet(session, fastapi_vm_id),
Jun 05 10:39:25 testing-hetzner python3[1400146]:                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 05 10:39:25 testing-hetzner python3[1400146]:   File "/opt/aleph-vm/aleph/vm/orchestrator/status.py", line 122, in check_internet
Jun 05 10:39:25 testing-hetzner python3[1400146]:     assert result["result"] == HTTPOk.status_code
Jun 05 10:39:25 testing-hetzner python3[1400146]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jun 05 10:39:25 testing-hetzner python3[1400146]: AssertionError

@github-actions github-actions bot added the BLUE This PR is simple and straightforward. label Jun 5, 2024
Copy link

codecov bot commented Jun 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.70%. Comparing base (a4e26a8) to head (d6abcad).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #628      +/-   ##
==========================================
+ Coverage   58.32%   58.70%   +0.37%     
==========================================
  Files          61       62       +1     
  Lines        5464     5485      +21     
  Branches      607      609       +2     
==========================================
+ Hits         3187     3220      +33     
+ Misses       2137     2125      -12     
  Partials      140      140              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aleph-im aleph-im deleted a comment from github-actions bot Jun 12, 2024
…us_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.
@hoh hoh requested a review from olethanh June 12, 2024 16:12
@hoh hoh merged commit b7e0ccf into main Jun 13, 2024
24 checks passed
@hoh hoh deleted the hoh-fix-internet-check branch June 13, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BLUE This PR is simple and straightforward.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants