mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 03:36:48 +00:00
perf(instances): a VM page does not wait for the guest agent's addresses
A running VM's page read its addresses while it rendered: the guest agent, when its channel is connected but it does not answer, holds the page (and a gunicorn worker) for its whole 10 s timeout, on every load. The page now shows them once it has loaded: vm_addresses.js asks the new instances/<pk>/addresses/ for each NIC's addresses and fills the header's IPv4 and each network card's IPv4 and IPv6.
This commit is contained in:
parent
bf736942eb
commit
aab8dbf1df
18 changed files with 600 additions and 449 deletions
20
static/js/vm_addresses.js
Normal file
20
static/js/vm_addresses.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// The VM's addresses come once the page has loaded: the guest agent may take
|
||||
// its whole timeout (instances.views.nic_addresses). An element with
|
||||
// data-address-family shows those of the NICs in data-address-mac (MACs
|
||||
// separated by spaces: not the guest's own bridges); data-empty when there
|
||||
// are none.
|
||||
(function () {
|
||||
const places = document.querySelectorAll("[data-address-family]");
|
||||
const show = (found) => {
|
||||
for (const place of places) {
|
||||
const nics = place.dataset.addressMac.split(" ").filter(Boolean).map((mac) => found[mac] || {});
|
||||
const addresses = nics.flatMap((nic) => nic[place.dataset.addressFamily] || []);
|
||||
place.textContent = addresses.join(", ") || place.dataset.empty;
|
||||
place.classList.toggle("text-body-secondary", !addresses.length);
|
||||
}
|
||||
};
|
||||
fetch(document.currentScript.dataset.url, {headers: {Accept: "application/json"}})
|
||||
.then((response) => (response.ok ? response.json() : {}))
|
||||
.catch(() => ({}))
|
||||
.then(show);
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue