1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

fix(console): a serial console worker's failure reaches socketiod's log

- The worker told why a console did not open or closed only in the user's
  terminal (as users see errors: a host that cannot be reached is not
  named). It now also logs the full reason to socketiod's own stderr, the
  journal or docker logs, which socketiod hands it as a descriptor.
- A refused token says the link has expired or the user may no longer
  open the console: a valid link for a user who lost access was told only
  that it had expired.
- A send that takes nothing (0 bytes) waits like a busy stream instead of
  spinning.
This commit is contained in:
catborise 2026-10-26 21:47:01 +03:00
parent 060a3cc86b
commit 6744838850
4 changed files with 26 additions and 6 deletions

View file

@ -242,8 +242,8 @@ class WorkerIsolationTestCase(Base):
while b"]" not in output:
select.select([fd], [], [], 5)
output += os.read(fd, 1024)
# 0-2: its terminal, 3: the listing itself
self.assertEqual(output.decode().strip(), "['0', '1', '2', '3']")
# 0-2: its terminal, 3: socketiod's log, 4: the listing itself
self.assertEqual(output.decode().strip(), "['0', '1', '2', '3', '4']")
def _open(fd):

View file

@ -70,8 +70,9 @@ def start_socketiod(test):
port = free_port()
env = dict(os.environ, DJANGO_SETTINGS_MODULE="socketiod_test_settings",
PYTHONPATH=os.pathsep.join([tmp.name, str(ROOT)]))
test.log = Path(tmp.name) / "socketiod.log" # its stderr, as the journal would have it
server = subprocess.Popen([sys.executable, str(SOCKETIOD), "-H", "127.0.0.1", "-p", str(port)],
cwd=ROOT, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
cwd=ROOT, env=env, stdout=subprocess.DEVNULL, stderr=test.log.open("w"))
test.addCleanup(lambda: (server.kill(), server.wait()))
end = time.monotonic() + 20
while time.monotonic() < end:
@ -125,6 +126,10 @@ class SocketiodProcessTestCase(TransactionTestCase):
time.sleep(0.05)
self.assertEqual(consoles(self.server.pid), [])
self.assertIsNone(self.server.poll())
# the operator finds why in socketiod's log, with the details the user is not shown
log = self.log.read_text()
for name in self.tokens:
self.assertIn("serial console of VM %s did not open" % name, log)
def test_a_client_without_a_valid_token_is_refused(self):
for token in ("", "22-no-such-vm"):