mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 01:16:10 +00:00
fix(computes): hosts that do not answer no longer keep the Computes page from the others
The Computes page read its hosts on a pool of eight threads shared by the process: eight hosts that hang held all of them for as long as they hung, and every other host was then shown not connected. Each host is now read on a thread of its own (a daemon thread, which does not keep the process from exiting), one at a time per host as before. The UUID of a host added before host UUIDs were kept is read on that thread too, within the page's wait, instead of after it. A host's charts asked for each reading without a time limit: a reading the host kept waiting left the charts saying "Updated" and stopped the polling. A reading now ends after 30 s; the charts then say since when they are not updated, and the next reading goes out.
This commit is contained in:
parent
a998e68757
commit
1f6cc15ddf
5 changed files with 93 additions and 32 deletions
|
|
@ -113,7 +113,7 @@ class GraphScriptTestCase(TestCase):
|
|||
script = (settings.BASE_DIR / "static/js/host_graphs.js").read_text()
|
||||
js = """
|
||||
const vm = require("vm");
|
||||
const charts = [], requests = [];
|
||||
const charts = [], requests = [], timeouts = [];
|
||||
const element = (dataset) => ({dataset, textContent: "", classList: {add: () => {}, remove: () => {}}});
|
||||
const elements = {graph_state: element(DATASET),
|
||||
cpu_now: element({}), mem_now: element({})};
|
||||
|
|
@ -129,7 +129,7 @@ class GraphScriptTestCase(TestCase):
|
|||
this.update = () => {};
|
||||
charts.push(this);
|
||||
}, {defaults: {}}),
|
||||
$: {getJSON: (url, params) => { requests.push(params); return {fail() { return this; }}; }},
|
||||
$: {ajax: (options) => { requests.push(options.data); timeouts.push(options.timeout); return {fail() { return this; }}; }},
|
||||
pollWhileVisible: (interval, request, onData) => { poll = {request, onData}; },
|
||||
};
|
||||
const context = vm.createContext(page);
|
||||
|
|
@ -144,7 +144,7 @@ class GraphScriptTestCase(TestCase):
|
|||
poll.onData({cpudata: null, memdata: {total: null, usage: null}, timeline: "t"});
|
||||
poll.request();
|
||||
const label = charts[0].options.plugins.tooltip.callbacks.label({dataset: {label: "Usage"}, formattedValue: "3", dataIndex: 0});
|
||||
console.log(JSON.stringify({requests, label, shown, state: elements.graph_state.textContent,
|
||||
console.log(JSON.stringify({requests, timeouts, label, shown, state: elements.graph_state.textContent,
|
||||
cpu: charts[0].data.datasets[0].data,
|
||||
mem: charts[1].data.datasets[0].data, memMax: charts[1].options.scales.y.max}));
|
||||
""".replace("SCRIPT", json.dumps(script)).replace("CHARTS", json.dumps(CHARTS_JS.read_text())).replace(
|
||||
|
|
@ -153,6 +153,8 @@ class GraphScriptTestCase(TestCase):
|
|||
self.assertEqual(out.returncode, 0, out.stderr)
|
||||
result = json.loads(out.stdout)
|
||||
self.assertEqual(result["requests"], [{}, {"cpu_sample": "token-1"}, {}])
|
||||
# a reading the host keeps waiting ends: the charts then say they are not updated
|
||||
self.assertEqual(result["timeouts"], [30000] * 3)
|
||||
self.assertEqual(result["cpu"], [3, None])
|
||||
# a host that could not be read leaves a gap and keeps the memory axis
|
||||
self.assertEqual((result["mem"], result["memMax"]), ([1, None], 2))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue