Skip to content

Commit

Permalink
Fix: Compatibility with the legacy VM could not be checked
Browse files Browse the repository at this point in the history
Solution: Add a dedicated endpoint that checks that the legacy VM can run on the node, and display it on the index/diagnostic page.
  • Loading branch information
hoh committed Feb 2, 2024
1 parent ea8c849 commit 932eba6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/aleph/vm/orchestrator/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
5 changes: 5 additions & 0 deletions src/aleph/vm/orchestrator/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down
7 changes: 5 additions & 2 deletions src/aleph/vm/orchestrator/views/static/helpers.js
Original file line number Diff line number Diff line change
@@ -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: []
Expand Down
39 changes: 39 additions & 0 deletions src/aleph/vm/orchestrator/views/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,31 @@ <h3>Virtualization</h3>
</div>
</div>

<div id="virtualization-legacy-checks">
<h3>Virtualization (legacy)</h3>
<p>
Virtualization
<span id="virtualization-legacy-check">
...
<span class="loader-container">
<span id="loader-one" class="loader"></span>
<span id="loader-two" class="loader"></span>
<span id="loader-three" class="loader"></span>
</span>
</span>
</p>
<div class="details">
<ul></ul>
</div>
<div class="help" style="display: none">
<p>
ℹ️ <a href="https://docs.aleph.im/nodes/compute/troubleshooting/#virtualization">
Troubleshoot virtualization
</a>
</p>
</div>
</div>

<div id="host-checks">
<h3>Host connectivity</h3>
<p>
Expand Down Expand Up @@ -208,6 +233,20 @@ <h2>Version</h2>
}
})();

(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();
Expand Down

0 comments on commit 932eba6

Please sign in to comment.