mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-01 16:36:06 +00:00
fix: worker warnings and CPU windows do not depend on a wall clock
The job panel warned "Worker unavailable" when the worker's last heartbeat was more than 60 s older than the browser's clock: a browser set two minutes ahead warned about a worker that had just beaten, and one behind hid a worker that had stopped. The server now says whether the worker is gone (worker_gone in the job panel's answer), by the same rule as the Jobs page. A host's CPU graph measured its averaging window with time.time(): a clock set back between two polls gave a negative window. It now uses time.monotonic(), as a VM's usage already does; a sample from before the server restarted is measured over a second again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kk4h2TcUiaWmU5MUszYSea
This commit is contained in:
parent
25e49c2aa2
commit
e83bdcbd44
9 changed files with 55 additions and 21 deletions
|
|
@ -22,7 +22,7 @@ function jobPanel(element, urls, csrfToken, initialIds, states, text) {
|
|||
var cancelling = {}; // id -> true: its cancel request runs
|
||||
var notice = ""; // why the last cancel failed, until dismissed
|
||||
(initialIds || []).forEach(function (id) { pending[id] = true; });
|
||||
var last = { jobs: [], others: [], short_operation: false, worker_last_seen: null };
|
||||
var last = { jobs: [], others: [], short_operation: false, worker_last_seen: null, worker_gone: false };
|
||||
var rendered = null; // the panel's last html: an unchanged one is not rebuilt (focus stays)
|
||||
var holding = false; // the panel set backgroundJobRunning (the please-wait dialog sets it too)
|
||||
if (initialIds && initialIds.length) {
|
||||
|
|
@ -101,8 +101,9 @@ function jobPanel(element, urls, csrfToken, initialIds, states, text) {
|
|||
var waiting = last.jobs.some(function (j) {
|
||||
return ["queued", "running", "cancelling"].indexOf(j.state) >= 0 && !j.in_request;
|
||||
});
|
||||
// the server tells: the browser's clock may be off
|
||||
var seen = last.worker_last_seen ? new Date(last.worker_last_seen) : null;
|
||||
if (waiting && (!seen || Date.now() - seen.getTime() > 60000)) {
|
||||
if (waiting && last.worker_gone) {
|
||||
html += '<div class="alert alert-warning mb-3" role="status">' + esc(text.worker_unavailable) + " "
|
||||
+ esc(seen ? seen.toLocaleString() : text.never) + ".</div>";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue