From 932eba63385c15bb99e2a997102adb0e69a203a8 Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Fri, 2 Feb 2024 13:02:27 +0100 Subject: [PATCH] Fix: Compatibility with the legacy VM could not be checked Solution: Add a dedicated endpoint that checks that the legacy VM can run on the node, and display it on the index/diagnostic page. --- src/aleph/vm/orchestrator/supervisor.py | 2 + src/aleph/vm/orchestrator/views/__init__.py | 5 +++ .../vm/orchestrator/views/static/helpers.js | 7 +++- .../orchestrator/views/templates/index.html | 39 +++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/aleph/vm/orchestrator/supervisor.py b/src/aleph/vm/orchestrator/supervisor.py index a2c5eb1fd..e541539a5 100644 --- a/src/aleph/vm/orchestrator/supervisor.py +++ b/src/aleph/vm/orchestrator/supervisor.py @@ -37,6 +37,7 @@ run_code_from_hostname, run_code_from_path, status_check_fastapi, + status_check_fastapi_legacy, status_check_host, status_check_ipv6, status_check_version, @@ -102,6 +103,7 @@ async def allow_cors_on_endpoint(request: web.Request): web.post("/control/machine/{ref}/reboot", operate_reboot), # /status APIs are used to check that the VM Orchestrator is running properly web.get("/status/check/fastapi", status_check_fastapi), + web.get("/status/check/fastapi/legacy", status_check_fastapi_legacy), web.get("/status/check/host", status_check_host), web.get("/status/check/version", status_check_version), web.get("/status/check/ipv6", status_check_ipv6), diff --git a/src/aleph/vm/orchestrator/views/__init__.py b/src/aleph/vm/orchestrator/views/__init__.py index 70309e3ea..99eed785e 100644 --- a/src/aleph/vm/orchestrator/views/__init__.py +++ b/src/aleph/vm/orchestrator/views/__init__.py @@ -210,6 +210,11 @@ async def status_check_fastapi(request: web.Request, vm_id: Optional[ItemHash] = ) +async def status_check_fastapi_legacy(request: web.Request): + """Check that the legacy FastAPI VM runs correctly""" + return await status_check_fastapi(request, vm_id=ItemHash(settings.LEGACY_CHECK_FASTAPI_VM_ID)) + + async def status_check_host(request: web.Request): """Check that the platform is supported and configured correctly""" diff --git a/src/aleph/vm/orchestrator/views/static/helpers.js b/src/aleph/vm/orchestrator/views/static/helpers.js index 46d12e4b6..8644a11aa 100644 --- a/src/aleph/vm/orchestrator/views/static/helpers.js +++ b/src/aleph/vm/orchestrator/views/static/helpers.js @@ -1,5 +1,8 @@ -async function fetchFastapiCheckStatus () { - const q = await fetch('/status/check/fastapi'); + +// Add optional "legacy" argument to this function +async function fetchFastapiCheckStatus (legacy = false) { + const path = legacy ? '/status/check/fastapi/legacy' : '/status/check/fastapi'; + const q = await fetch(path); let res = { status: q.status, details: [] diff --git a/src/aleph/vm/orchestrator/views/templates/index.html b/src/aleph/vm/orchestrator/views/templates/index.html index d7b449f21..96d229864 100644 --- a/src/aleph/vm/orchestrator/views/templates/index.html +++ b/src/aleph/vm/orchestrator/views/templates/index.html @@ -69,6 +69,31 @@

Virtualization

+
+

Virtualization (legacy)

+

+ Virtualization + + ... + + + + + + +

+
+
    +
    + +
    +

    Host connectivity

    @@ -208,6 +233,20 @@

    Version

    } })(); + (async () => { + try { + const { status, details } = await fetchFastapiCheckStatus(legacy=true); + document.getElementById('virtualization-legacy-check').innerHTML = status; + if(Object.keys(details).length > 0){ + const detailsDiv = document.querySelector("#virtualization-legacy-checks .details ul"); + detailsDiv.innerHTML = objectToString(details); + document.querySelector("#virtualization-legacy-checks .help").style.display = "block"; + } + } catch (err) { + console.error('Could not fetch api status', err); + } + })(); + (async () => { try { const { status, details } = await fetchHostCheckStatus();